<html><head></head><body>--- man2html-linux.patch	Sat Apr 27 12:09:41 1996
+++ ../man2html.c	Thu Mar 21 17:35:39 1996
@@ -1,850 +1,3042 @@
---- ../man2html.c	Thu Mar 21 17:35:39 1996
-+++ man2html.c	Sat Apr 27 11:51:46 1996
-@@ -5,6 +5,18 @@
- ** Permission is granted to distribute, modify and use this program as long
- ** as this comment is not removed or changed.
- */
-+
-+/* 
-+ * man2html-linux-1.0/1.1
-+ * This version modified for Redhat/Caldera linux - March 1996.
-+ * Michael Hamilton <michael@actrix.gen.nz>.
-+ *
-+ * man2html-linux-1.2
-+ * Added support for BSD mandoc pages - I didn't have any documentation
-+ * on the mandoc macros, so I may have missed some.
-+ * Michael Hamilton <michael@actrix.gen.nz>.
-+ */
-+
- /*
- ** If you want to use this program for your WWW server, adjust the line
- ** which defines the CGIBASE or compile it with the -DCGIBASE='"..."' option.
-@@ -92,8 +104,12 @@
- #include <time.h>
- #include <sys time.h="">
- 
-+#ifndef TOPLEVELDOC
-+#define TOPLEVELDOC "/home/httpd/html/man.html"
-+#endif
-+
- #ifndef CGIBASE
--#define CGIBASE "http://wsinwp01.win.tue.nl:1234/cgi-bin/man2html"
-+#define CGIBASE "http://localhost/cgi-bin/man2html"
- #endif
- 
- #ifndef NROFF
-@@ -109,6 +125,21 @@
- /* timeformat for signature */
- #define TIMEFORMAT "%T GMT, %B %d, %Y"
- 
-+/* BSD mandoc Bl/El lists to HTML list types */
-+#define BL_DESC_LIST   1
-+#define BL_BULLET_LIST 2
-+#define BL_ENUM_LIST   4
-+
-+/* BSD mandoc Bd/Ed example(?) blocks */
-+#define BD_LITERAL  1
-+#define BD_INDENT   2
-+
-+/* Don't bother with free(), it will just slow us down, the ultimate
-+   free will be exit() anyway.  Hack to fix a malloc bug that I couldn't
-+   track down (michael@actrix.gen.nz).
-+   */
-+#define free(x)
-+
- char *manpath[] = { "/",
- 		    "/usr/X11/man/",
- 		    "/usr/man/",
-@@ -128,27 +159,47 @@
- 
- char *sections = "123456789nl";
- 
-+
- void usage(void)
- {
--    printf("Content-type: text/html\n\n"
--	   "\n"
--	   "<title>Manual Pages</title>\n"
--	   "\n"
--	   "<h1>Manual Pages</h1>\n"
--	   "This is a HyperText interface to the UNIX manpages.\n"
--	   "You can enter a program name, the section, an extra\n"
--	   "directory (using -M) or a full name. For example\n"
--	   "<ul><li><tt>elm</tt>\n"
--	   "</li><li><tt>elm 1</tt>\n"
--	   "</li><li><tt>-M /usr/local/man elm</tt>\n"
--	   "</li><li><tt>/local/gcc/man/man1/gperf.1</tt>\n"
--	   "</li></ul>\n"
--	   "<isindex>\n"
--	   "<p>\n"
--	   "This man2html converter was written by \n"
--	   "<a href="\&quot;http://wsinwp01.win.tue.nl:1234/index.html\&quot;">"
--	   "Richard Verhoeven</a>\n"
--	   "\n");
-+    char buffer[500];
-+    FILE *toplevel = fopen(TOPLEVELDOC, "r");
-+    
-+    if (!toplevel &amp;&amp; errno == ENOENT) {
-+      printf("Content-type: text/html\n\n"
-+	     "\n"
-+	     "<title>Manual Pages</title>\n"
-+	     "\n"
-+	     "</p><h1>Manual Pages</h1>\n"
-+	     "This is a HyperText interface to the UNIX manpages.\n"
-+	     "You can enter a program name, the section, an extra\n"
-+	     "directory (using -M) or a full name. For example\n"
-+	     "<ul><li><tt>elm</tt>\n"
-+	     "</li><li><tt>elm 1</tt>\n"
-+	     "</li><li><tt>-M /usr/local/man elm</tt>\n"
-+	     "</li><li><tt>/local/gcc/man/man1/gperf.1</tt>\n"
-+	     "</li></ul>\n"
-+	     "<isindex>\n"
-+	     "<p>\n"
-+	     "This man2html converter was written by \n"
-+	     "<a href="\&quot;http://wsinwp01.win.tue.nl:1234/index.html\&quot;">"
-+	     "Richard Verhoeven</a>\n"
-+	     "\n");
-+      exit(0);      
-+    }
-+
-+    if (!toplevel) {
-+      fprintf(stderr, "Error openning %s: %s\n", TOPLEVELDOC, strerror(errno));
-+      exit(EXIT_FAILURE);
-+    }
-+    while (fgets(buffer, 500, toplevel)) {
-+        fputs(buffer,stdout);
-+    }
-+    if (!feof(toplevel)) {
-+        fprintf(stderr, "Error reading %s\n", TOPLEVELDOC, strerror(errno));
-+	exit(EXIT_FAILURE);
-+    }
-+    fclose(toplevel);
-     exit(0);
- }
- 
-@@ -315,12 +366,14 @@
- int scaninbuff=0;
- int itemdepth=0;
- int dl_set[20]= { 0 };
-+int list_options[20][50];
- int still_dd=0;
- int tabstops[20] = { 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96 };
- int maxtstop=12;
- int curpos=0;
- 
- extern char *scan_troff(char *c, int san, char **result);
-+extern char *scan_troff_mandoc(char *c, int san, char **result);
- 
- static char **argument=NULL;
- 
-@@ -465,10 +518,14 @@
- 		    t=*e;
- 		    *e='\0';
- 		    if (subsec)
--			printf("<a href="\&quot;../man%c/%s.%c%c\&quot;">%s</a>",
-+			printf("<a href="\&quot;&quot;" -+="" cgibase="" "?man%c="" %s.%c%c\"="">%s</a>",
- 			       sec, h, sec, tolower(subsec), h);
- 		    else
--			printf("<a href="\&quot;../man%c/%s.%c\&quot;">%s</a>",
-+			printf("<a href="\&quot;&quot;" -+="" cgibase="" "?man%c="" %s.%c\"="">%s</a>",
- 			       sec, h, sec, h);
- 		    *e=t;
- 		    c=e;
-@@ -853,7 +910,7 @@
-     TABLEITEM *next;
- };
- 
--static TABLEITEM emptyfield = {NULL,0,0,0,1,1,0,0,0,0,NULL};
-+static TABLEITEM emptyfield = {NULL,0,0,0,1,1,0,0,0,0,0,NULL};
- typedef struct TABLEROW TABLEROW;
- 
- struct TABLEROW {
-@@ -1700,6 +1757,11 @@
- 
- char *scan_request(char *c)
- {
-+				  /* BSD Mandoc stuff */
-+    static int mandoc_synopsis=0; /* True if we are in the synopsis section */
-+    static int mandoc_command=0;  /* True if this is mandoc page */
-+    static int mandoc_bd_options; /* Only copes with non-nested Bd's */
-+
-     int i,j,mode=0;
-     char *h;
-     char *wordlist[20];
-@@ -2193,7 +2255,11 @@
- 	    c=skip_till_newline(c);
- 	    curpos=0;
- 	    break;
--	case V('P','D'): c=skip_till_newline(c); break;
-+	case V('P','D'): 
-+	    c=skip_till_newline(c); 
-+	    c=scan_troff(c,1,NULL); /* In case of ".TP\n.PD 0\ntext" */
-+	    break;
-+	case V('R','s'):	/* BSD mandoc */
- 	case V('R','S'):
- 	    sl=fill_words(c+j, wordlist, &amp;words);
- 	    j=1;
-@@ -2206,8 +2272,9 @@
- 		curpos=0;
- 		break;
- 	    }
-+	case V('R','e'):	/* BSD mandoc */
- 	case V('R','E'):
--	    if (itemdepth) {
-+	    if (itemdepth &gt; 0) {
- 		if (dl_set[itemdepth]) out_html("");
- 		out_html("\n");
- 		itemdepth--;
-@@ -2230,15 +2297,20 @@
- 	    c=scan_troff(c,1,NULL);
- 	    out_html(change_to_size('0'));
- 	    break;
-+	case V('S','s'):	/* BSD mandoc */
-+	    mandoc_command = 1;
- 	case V('S','S'):
- 	    mode=1;
-+	case V('S','h'):	/* BSD mandoc */
-+				/* hack for fallthru from above */
-+	    mandoc_command = !mode || mandoc_command; 
- 	case V('S','H'):
- 	    c=c+j;
- 	    if (*c=='\n') c++;
- 	    while (itemdepth || dl_set[itemdepth]) {
- 		out_html("\n");
- 		if (dl_set[itemdepth]) dl_set[itemdepth]=0;
--		else itemdepth--;
-+		else if (itemdepth &gt; 0) itemdepth--;
- 	    }
- 	    out_html(change_to_font(0));
- 	    out_html(change_to_size(0));
-@@ -2253,7 +2325,8 @@
- 	    /* &nbsp; for mosaic users */
- 	    if (mode) out_html("\"&gt;&nbsp;\n</p><h3>");
- 	    else out_html("\"&gt;&nbsp;\n</h3><h2>");
--	    c=scan_troff(c,1,NULL);
-+	    mandoc_synopsis = strncmp(c, "SYNOPSIS", 8) == 0;
-+	    c = mandoc_command ? scan_troff_mandoc(c,1,NULL) : scan_troff(c,1,NULL);
- 	    if (mode) out_html("</h2>\n");
- 	    else out_html("\n");
- 	    curpos=0;
-@@ -2261,6 +2334,8 @@
- 	case V('T','S'):
- 	    c=scan_table(c);
- 	    break;
-+	case V('D','t'):	/* BSD mandoc */
-+	    mandoc_command = 1;
- 	case V('T','H'):
- 	    if (!output_possible) {
- 		sl = fill_words(c+j, wordlist, &amp;words);
-@@ -2284,7 +2359,11 @@
- 		    } else out_html(")");
- 		    out_html("<br><a href="\&quot;#index\&quot;">Index</a>\n");
- 		    *sl='\n';
-+		    printf("<br><a href="\&quot;&quot;" -+="" cgibase="" "\"="">Return to Main Contents</a>\n");
- 		    out_html("<hr>\n");
-+		    if (mandoc_command) out_html("<br>BSD mandoc<br>");
- 		}
- 		c=sl+1;
- 	    } else c=skip_till_newline(c);
-@@ -2415,6 +2494,460 @@
- 	    }
- 	    c=skip_till_newline(c);
- 	    break;
-+	case V('B','l'):	/* BSD mandoc */
-+	  {
-+	    char list_options[500]; 
-+	    char *nl = strchr(c,'\n');
-+	    c=c+j;
-+	    if (dl_set[itemdepth]) {  /* These things can nest. */
-+	        itemdepth++;
-+	    }
-+	    if (nl) {		  /* Parse list options */
-+	        strncpy(list_options, c, nl - c);
-+	        list_options[nl - c] = '\0';
-+	    }
-+	    if (strstr(list_options, "-bullet")) { /* HTML Unnumbered List */
-+	        dl_set[itemdepth] = BL_BULLET_LIST;
-+	        out_html("<ul>\n");
-+	    }
-+	    else if (strstr(list_options, "-enum")) { /* HTML Ordered List */
-+	        dl_set[itemdepth] = BL_ENUM_LIST;
-+	        out_html("<ol>\n");
-+	    }
-+	    else {		  /* HTML Descriptive List */
-+	        dl_set[itemdepth] = BL_DESC_LIST;
-+	        out_html("<dl compact="">\n");
-+	    }
-+	    if (fillout) out_html("<p>\n"); else {
-+		out_html(NEWLINE);
-+		NEWLINE[0]='\n';
-+	    }
-+	    curpos=0;
-+	    c=skip_till_newline(c);
-+	    break;
-+	  }
-+	case V('E','l'):	/* BSD mandoc */
-+	    c=c+j;
-+	    if (dl_set[itemdepth] &amp; BL_DESC_LIST) {
-+		out_html("</p></dl>\n");
-+	    }
-+	    else if (dl_set[itemdepth] &amp; BL_BULLET_LIST) {
-+		out_html("</ol></ul>\n");
-+	    }
-+	    else if (dl_set[itemdepth] &amp; BL_ENUM_LIST) {
-+		out_html("\n");
-+	    }
-+	    dl_set[itemdepth]=0;
-+	    if (itemdepth &gt; 0) itemdepth--;
-+	    if (fillout) out_html("<p>\n"); else {
-+		out_html(NEWLINE);
-+		NEWLINE[0]='\n';
-+	    }
-+	    curpos=0;
-+	    c=skip_till_newline(c);
-+	    break;
-+	case V('I','t'):	/* BSD mandoc */
-+	    c=c+j;
-+	    if (strncmp(c, "Xo", 2) == 0 &amp;&amp; isspace(*(c+2))) {
-+	        c = skip_till_newline(c); 
-+	    }
-+	    if (dl_set[itemdepth] &amp; BL_DESC_LIST) {
-+	        out_html("</p><dt>");
-+		out_html(change_to_font('B'));
-+	        if (*c=='\n') {	  /* Don't allow embedded comms after a newline */
-+		    c++;	  
-+		    c=scan_troff(c,1,NULL);
-+		}
-+		else {		  /* Do allow embedded comms on the same line. */
-+		    c=scan_troff_mandoc(c,1,NULL);
-+		}
-+		out_html(change_to_font('R'));
-+		out_html(NEWLINE);
-+		out_html("</dt><dd>");
-+	    }
-+	    else if (dl_set[itemdepth] &amp; (BL_BULLET_LIST | BL_ENUM_LIST)) {
-+	        out_html("<li>");
-+		c=scan_troff_mandoc(c,1,NULL);
-+		out_html(NEWLINE);
-+	    }
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('B','k'):	/* BSD mandoc */
-+	case V('E','k'):	/* BSD mandoc */
-+	case V('D','d'):	/* BSD mandoc */
-+	case V('O','s'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('B','t'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    out_html(" is currently in beta test.");
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('B','x'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    out_html("BSD ");
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('D','l'):	/* BSD mandoc */
-+	    c=c+j;
-+	    out_html(NEWLINE);
-+	    out_html("<blockquote>");	    
-+	    out_html(change_to_font('L'));
-+	    if (*c=='\n') c++;
-+	    c=scan_troff_mandoc(c, 1, NULL);	    
-+	    out_html(change_to_font('R'));
-+	    out_html("</blockquote>");	    
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('B','d'):	/* BSD mandoc */
-+	  {			/* Seems like a kind of example/literal mode */
-+	    char bd_options[500]; 
-+	    char *nl = strchr(c,'\n');
-+	    c=c+j;
-+	    if (nl) {
-+	      strncpy(bd_options, c, nl - c);
-+	      bd_options[nl - c] = '\0';
-+	    }
-+	    out_html(NEWLINE);
-+	    mandoc_bd_options = 0; /* Remember options for terminating Bl */
-+	    if (strstr(bd_options, "-offset indent")) {
-+	        mandoc_bd_options |= BD_INDENT;
-+	        out_html("<blockquote>\n");
-+	    }
-+	    if (   strstr(bd_options, "-literal")
-+		|| strstr(bd_options, "-unfilled")) {
-+	        if (fillout) {
-+		    mandoc_bd_options |= BD_LITERAL;
-+		    out_html(change_to_font(0));
-+		    out_html(change_to_size('0'));
-+		    out_html("<pre>\n");
-+		}
-+		curpos=0;
-+		fillout=0;
-+	    }
-+	    c=skip_till_newline(c);
-+	    break;
-+	  }
-+	case V('E','d'):	/* BSD mandoc */
-+	    if (mandoc_bd_options &amp; BD_LITERAL) {
-+	        if (!fillout) {
-+		    out_html(change_to_font(0));
-+		    out_html(change_to_size('0'));
-+		    out_html("</pre>\n");
-+		}
-+	    }
-+	    if (mandoc_bd_options &amp; BD_INDENT)
-+	        out_html("</blockquote>\n");
-+	    curpos=0;
-+	    fillout=1;
-+	    c=skip_till_newline(c);
-+	    break;
-+	case V('B','e'):	/* BSD mandoc */
-+	    c=c+j;
-+	    if (fillout) out_html("<p>"); else {
-+		out_html(NEWLINE);
-+		NEWLINE[0]='\n';
-+	    }
-+	    curpos=0;
-+	    c=skip_till_newline(c);
-+	    break;
-+	case V('X','r'):	/* BSD mandoc */
-+	    {
-+	      /* Translate xyz 1 to xyz(1) 
-+	       * Allow for multiple spaces.  Allow the section to be missing.
-+	       */
-+	      char buff[500];
-+	      char *bufptr;
-+	      trans_char(c,'"','\a');
-+	      bufptr = buff;
-+	      c = c+j;
-+	      if (*c == '\n') c++; /* Skip spaces */
-+	      while (isspace(*c) &amp;&amp; *c != '\n') c++;
-+	      while (isalnum(*c)) { /* Copy the xyz part */
-+		*bufptr = *c;
-+		bufptr++;
-+		c++;
-+	      }
-+	      while (isspace(*c) &amp;&amp; *c != '\n') c++;	/* Skip spaces */
-+	      if (isdigit(*c)) { /* Convert the number if there is one */
-+		*bufptr = '(';
-+		bufptr++; 
-+		while (isalnum(*c)) { 
-+		  *bufptr = *c; 
-+		  bufptr++;
-+		  c++;
-+		}
-+		*bufptr = ')';
-+		bufptr++;
-+	      }
-+
-+	      while (*c != '\n') { /* Copy the remainder */
-+		if (!isspace(*c)) {
-+		  *bufptr = *c;
-+		  bufptr++;
-+		}
-+		c++;
-+	      }
-+	      *bufptr = '\n';
-+	      scan_troff_mandoc(buff, 1, NULL);
-+
-+	      out_html(NEWLINE);
-+	      if (fillout) curpos++; else curpos=0;
-+	    }
-+	    break;	  
-+	case V('F','l'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    out_html("-");
-+	    if (*c!='\n') {
-+	        out_html(change_to_font('B'));
-+	        c=scan_troff_mandoc(c, 1, NULL);
-+	        out_html(change_to_font('R'));
-+            }
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('P','a'):	/* BSD mandoc */
-+	case V('P','f'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('P','p'):	/* BSD mandoc */
-+	    if (fillout) out_html("</p><p>\n"); else {
-+		out_html(NEWLINE);
-+		NEWLINE[0]='\n';
-+	    }
-+	    curpos=0;
-+	    c=skip_till_newline(c);
-+	    break;
-+	case V('D','q'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    out_html("``");
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html("''");
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('O','p'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    out_html(change_to_font('R'));
-+	    out_html("[");
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html(change_to_font('R'));
-+	    out_html("]");
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('O','o'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    out_html(change_to_font('R'));
-+	    out_html("[");
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('O','c'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html(change_to_font('R'));
-+	    out_html("]");
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('P','q'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    out_html("(");
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html(")");
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('Q','l'):	/* BSD mandoc */
-+	  {			/* Single quote first word in the line */
-+	    char *sp;
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    sp = c;	  
-+	    do {		/* Find first whitespace after the 
-+				 * first word that isn't a mandoc macro 
-+				 */
-+	      while (*sp &amp;&amp; isspace(*sp)) sp++;	    
-+	      while (*sp &amp;&amp; !isspace(*sp)) sp++;
-+	    } while (*sp &amp;&amp; isupper(*(sp-2)) &amp;&amp; islower(*(sp-1)));
-+
-+				/* Use a newline to mark the end of text to 
-+				 * be quoted 
-+				 */
-+	    if (*sp) *sp = '\n';
-+	    out_html("`");	/* Quote the text */
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html("'");
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	  }
-+	case V('S','q'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    out_html("`");
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html("'");
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('A','r'):	/* BSD mandoc */
-+            /* parse one line in italics */
-+	    out_html(change_to_font('I'));
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') {	/* An empty Ar means "file ..." */
-+	        out_html("file ...");
-+	    }
-+	    else {
-+	        c=scan_troff_mandoc(c, 1, NULL);
-+	    }
-+	    out_html(change_to_font('R'));
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('A','d'):	/* BSD mandoc */
-+	case V('E','m'):	/* BSD mandoc */
-+	case V('V','a'):	/* BSD mandoc */
-+	case V('X','c'):	/* BSD mandoc */
-+            /* parse one line in italics */
-+	    out_html(change_to_font('I'));
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html(change_to_font('R'));
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('N','d'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    out_html(" - ");
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('N','m'):	/* BSD mandoc */
-+	  {
-+	    static char mandoc_name[100] = "";
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (mandoc_synopsis) {    /* Break lines only in the Synopsis. 
-+				       * The Synopsis section seems to be treated
-+				       * as a special case - Bummer!
-+				       */
-+	        static int count = 0; /* Don't break on the first Nm */
-+	        if (count) {
-+		    out_html("<br>");
-+		}
-+		else {
-+		    char *end = strchr(c, '\n');
-+		    if (end) {	/* Remember the name for later. */
-+		        strncpy(mandoc_name, c, end - c);
-+		    }
-+		}
-+		count++;
-+	    }			
-+	    out_html(change_to_font('B'));
-+	    while (*c == ' '|| *c == '\t') c++;
-+	    if (*c == '\n') {	/* If Nm has no argument, use one from an earlier
-+				 * Nm command that did have one.  Hope there aren't
-+				 * too many commands that do this.
-+				 */
-+	        out_html(mandoc_name);
-+	    } 
-+	    else {
-+	        c=scan_troff_mandoc(c, 1, NULL);
-+	    }
-+	    out_html(change_to_font('R'));
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	  }
-+	case V('C','d'):	/* BSD mandoc */
-+	case V('C','m'):	/* BSD mandoc */
-+	case V('I','c'):	/* BSD mandoc */
-+	case V('M','s'):	/* BSD mandoc */
-+	case V('O','r'):	/* BSD mandoc */
-+	case V('S','y'):	/* BSD mandoc */
-+            /* parse one line in bold */
-+	    out_html(change_to_font('B'));
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html(change_to_font('R'));
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('D','v'):	/* BSD mandoc */
-+	case V('E','v'):	/* BSD mandoc */
-+	case V('F','r'):	/* BSD mandoc */
-+	case V('L','i'):	/* BSD mandoc */
-+	case V('N','o'):	/* BSD mandoc */
-+	case V('N','s'):	/* BSD mandoc */
-+	case V('T','n'):	/* BSD mandoc */
-+	case V('n','N'):	/* BSD mandoc */
-+	    trans_char(c,'"','\a');
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    out_html(change_to_font('B'));
-+	    c=scan_troff_mandoc(c, 1, NULL);
-+	    out_html(change_to_font('R'));
-+	    out_html(NEWLINE);
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('%','A'):	/* BSD mandoc biblio stuff */
-+	case V('%','D'):
-+	case V('%','N'):
-+	case V('%','O'):
-+	case V('%','P'):
-+	case V('%','Q'):
-+	case V('%','V'):
-+	    c=c+j;
-+	    if (*c=='\n') c++;
-+	    c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
-+	case V('%','B'):
-+	case V('%','J'):
-+	case V('%','R'):
-+	case V('%','T'):
-+	    c=c+j;
-+	    out_html(change_to_font('I'));
-+	    if (*c=='\n') c++;
-+	    c=scan_troff(c, 1, NULL); /* Don't allow embedded mandoc coms */
-+	    out_html(change_to_font('R'));
-+	    if (fillout) curpos++; else curpos=0;
-+	    break;
- 	default:
-             /* search macro database of self-defined macros */
- 	    owndef = defdef;
-@@ -2429,7 +2962,7 @@
- 		for (i=1;i<words; i++)="" wordlist[i][-1]="\0" ;="" -="" for="" (i="0;" i<words;="" {="" char="" *h="NULL;" --="" scan_troff(wordlist[i],1,&h);="" -+="" scan_troff_mandoc(wordlist[i],1,&h);="" wordlist[i]="h;" }="" -@@="" -2438,13="" +2971,34="" @@="" oldargument="argument;" argument="wordlist;" onff="newline_for_fun;" scan_troff(owndef-="">st+deflen+2, 0, NULL);
-+		scan_troff_mandoc(owndef-&gt;st+deflen+2, 0, NULL);
- 		newline_for_fun=onff;
- 		argument=oldargument;
- 		for (i=0; i<words; i++)="" if="" (wordlist[i])="" free(wordlist[i]);="" -="" *sl="\n" ;="" --="" }="" else="" -+="" ((isupper(*c)="" &&="" islower(*(c+1)))="" ||="" (islower(*c)="" isupper(*(c+1)))="" )="" {="" *="" let="" through="" any="" bsd="" mandoc="" commands="" that="" haven't="" been="" delt="" with.="" i="" don't="" want="" to="" miss="" anything="" out="" of="" the="" text.="" char="" buf[4];="" strncpy(buf,c,2);="" buf[2]=" " buf[3]="\0" out_html(buf);="" print="" command="" (it="" might="" just="" be="" text).="" c="c+j;" trans_char(c,'"','\a');="" (*c="='\n')" c++;="" out_html(change_to_font('r'));="" 1,="" null);="" out_html(newline);="" (fillout)="" curpos++;="" curpos="0;" break;="" -@@="" -2458,6="" +3012,9="" @@="" static="" int="" contained_tab="0;" -+static="" mandoc_line="0;" signals="" whether="" look="" for="" embedded="" commands.="" *scan_troff(char="" *c,="" san,="" **result)="" san="" :="" stop="" at="" newline="" -2490,7="" +3047,9="" h="c;" start="" scanning="" while="" (*h="" (!san="" newline_for_fun="" *h!="\n" ))="" h++;="" flushibp;="" -2500,6="" +3059,14="" (san="" h[-1]="='\n')" h--;="" (mandoc_line="" *(h)="" isupper(*(h))="" *(h+1)="" islower(*(h+1))="" *(h+2)="" isspace(*(h+2)))="" imbedded="" eg="" ".it="" fl="" ar="" arg1="" arg2"="" -2629,6="" +3196,35="" return="" h;="" -+char="" *scan_troff_mandoc(char="" -+{="" *ret,="" *end="c;" oldval="mandoc_line;" (*end="" !="\n" end++;="" (end=""> c + 2
-+        &amp;&amp; ispunct(*(end - 1)) 
-+	&amp;&amp; isspace(*(end - 2)) &amp;&amp; *(end - 2) != '\n') {
-+      /* Don't format lonely punctuation E.g. in "xyz ," format
-+       * the xyz and then append the comma removing the space.
-+       */
-+        *(end - 2) = '\n';
-+	ret = scan_troff(c, san, result);
-+        *(end - 2) = *(end - 1);
-+        *(end - 1) = ' ';
-+    }
-+    else {
-+	ret = scan_troff(c, san, result);
-+    }
-+    mandoc_line = oldval;
-+    return ret;
-+}
-+
-+
- char *sectionname=NULL;
- STRDEF *foundpages=NULL;
- 
-@@ -2656,7 +3252,7 @@
- 	    cmpbuf[n]=sections[j];
- 	    if ((dr=opendir(smfbuf))) {
- 		while ((de=readdir(dr))) {
--		    if (!strncmp(de-&gt;d_name, cmpbuf, n+1)) {
-+		    if (!strncasecmp(de-&gt;d_name, cmpbuf, n+1)) {
- 			int stlen;
- 			if (h) {
- 			    h-&gt;next=(STRDEF*) malloc(sizeof(STRDEF));
-@@ -3003,7 +3599,7 @@
-     while (itemdepth || dl_set[itemdepth]) {
- 	out_html("\n");
- 	if (dl_set[itemdepth]) dl_set[itemdepth]=0;
--	else itemdepth--;
-+	else if (itemdepth &gt; 0) itemdepth--;
-     }
-     out_html(change_to_font(0));
-     out_html(change_to_size(0));
+/*
+** This program was written by Richard Verhoeven (NL:5482ZX35)
+** at the Eindhoven University of Technology. Email: rcb5@win.tue.nl
+**
+** Permission is granted to distribute, modify and use this program as long
+** as this comment is not removed or changed.
+*/
+/*
+** If you want to use this program for your WWW server, adjust the line
+** which defines the CGIBASE or compile it with the -DCGIBASE='"..."' option.
+**
+** You have to adjust the built-in manpath to your local system. Note that
+** every directory should start and end with the '/' and that the first
+** directory should be "/" to allow a full path as an argument.
+**
+** The program first check if PATH_INFO contains some information.
+** If it does (t.i. man2html/some/thing is used), the program will look
+** for a manpage called PATH_INFO in the manpath.
+**
+** Otherwise the manpath is searched for the specified command line argument,
+** where the following options can be used:
+**
+** name      name of manpage (csh, printf, xv, troff)
+** section   the section (1 2 3 4 5 6 7 8 9 n l 1v ...)
+** -M path   an extra directory to look for manpages (replaces "/")
+**
+** If man2html finds multiple manpages that satisfy the options, an index
+** is displayed and the user can make a choice. If only one page is
+** found, that page will be displayed.
+**
+** man2html will add links to the converted manpages. The function add_links
+** is used for that. At the moment it will add links as follows, where   
+**     indicates what should match to start with:
+** ^^^
+** Recognition           Item            Link
+** ----------------------------------------------------------
+** name(*)               Manpage         ../man?/name.*
+**     ^
+** name@hostname         Email address   mailto:name@hostname
+**     ^
+** method://string       URL             method://string
+**       ^^^
+** www.host.name         WWW server      http://www.host.name
+** ^^^^
+** ftp.host.name         FTP server      ftp://ftp.host.name
+** ^^^^
+** <file.h>              Include file    file:/usr/include/file.h
+**      ^^^
+**
+** Since man2html does not check if manpages, hosts or email addresses exist,
+** some links might not work. For manpages, some extra checks are performed
+** to make sure not every () pair creates a link. Also out of date pages
+** might point to incorrect places.
+**
+** The program will not allow users to get system specific files, such as
+** /etc/passwd. It will check that "man" is part of the specified file and
+** that  "/../" isn't. Even if someone manages to get such file, man2html will
+** handle it like a manpage and will usually not produce any output (or crash).
+**
+** If you find any bugs when normal manpages are converted, please report
+** them to me (rcb5@win.tue.nl) after you have checked that man(1) can handle
+** the manpage correct.
+**
+** Known bugs and missing features:
+**
+**  * Equations are not converted at all.
+**  * Tables are converted but some features are not possible in html.
+**  * The tabbing environment is converted by counting characters and adding
+**    spaces. This might go wrong (outside </file.h></words;></words;></p><pre>)
+**  * Some pages look beter if man2html works in troff mode, especially pages
+**    with tables. You can deside at compile time which made you want to use.
+**
+**    -DNROFF=0     troff mode
+**    -DNROFF=1     nroff mode   (default)
+**
+**    if you install both modes, you should compile with the correct CGIBASE.
+**  * Some manpages rely on the fact that troff/nroff is used to convert
+**    them and use features which are not descripted in the man manpages.
+**    (definitions, calculations, conditionals, requests). I can't guarantee
+**    that all these features work on all manpages. (I didn't have the
+**    time to look through all the available manpages.)
+*/
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys stat.h="">
+#include <dirent.h>
+#include <ctype.h>
+#include <sys types.h="">
+#include <time.h>
+#include <sys time.h="">
+
+#ifndef CGIBASE
+#define CGIBASE "http://wsinwp01.win.tue.nl:1234/cgi-bin/man2html"
+#endif
+
+#ifndef NROFF
+#define NROFF 1
+#endif
+
+char *signature = "<hr>\n"
+"This document was created by\n"
+"<a href="\&quot;&quot;CGIBASE&quot;\&quot;">man2html</a>,\n"
+"using the manual pages.<br>\n"
+"Time: %s\n";
+
+/* timeformat for signature */
+#define TIMEFORMAT "%T GMT, %B %d, %Y"
+
+char *manpath[] = { "/",
+		    "/usr/X11/man/",
+		    "/usr/man/",
+		    "/usr/local/man/",
+		    "/usr/exp/man/",
+		    "/usr/openwin/man/",
+		    "/usr/tex/man/",
+		    "/usr/www/man/",
+		    "/usr/lang/man/",
+		    "/usr/gnu/man/",
+		    "/usr/motif/man/",
+		    "/usr/titools/man/",
+		    "/usr/sunpc/man/",
+		    "/usr/ncd/man/",
+		    "/usr/newsprint/man/",
+		    NULL };
+
+char *sections = "123456789nl";
+
+void usage(void)
+{
+    printf("Content-type: text/html\n\n"
+	   "\n"
+	   "<title>Manual Pages</title>\n"
+	   "\n"
+	   "<h1>Manual Pages</h1>\n"
+	   "This is a HyperText interface to the UNIX manpages.\n"
+	   "You can enter a program name, the section, an extra\n"
+	   "directory (using -M) or a full name. For example\n"
+	   "<ul><li><tt>elm</tt>\n"
+	   "</li><li><tt>elm 1</tt>\n"
+	   "</li><li><tt>-M /usr/local/man elm</tt>\n"
+	   "</li><li><tt>/local/gcc/man/man1/gperf.1</tt>\n"
+	   "</li></ul>\n"
+	   "<isindex>\n"
+	   "<p>\n"
+	   "This man2html converter was written by \n"
+	   "<a href="\&quot;http://wsinwp01.win.tue.nl:1234/index.html\&quot;">"
+	   "Richard Verhoeven</a>\n"
+	   "\n");
+    exit(0);
+}
+
+/* below this you should not change anything unless you know a lot
+** about this program or about troff.
+*/
+
+
+typedef struct STRDEF STRDEF;
+struct STRDEF {
+    int nr,slen;
+    char *st;
+    STRDEF *next;
+};
+
+typedef struct INTDEF INTDEF;
+struct INTDEF {
+    int nr;
+    int val;
+    int incr;
+    INTDEF *next;
+};
+
+static char NEWLINE[2]="\n";
+static char idxlabel[6] = "ixAAA";
+
+#define INDEXFILE "/tmp/manindex.list"
+
+char *fname;
+FILE *idxfile;
+
+STRDEF *chardef, *strdef, *defdef;
+INTDEF *intdef;
+
+#define V(A,B) ((A)*256+(B))
+
+INTDEF standardint[] = {
+    { V('n',' '), NROFF,0, NULL },
+    { V('t',' '), 1-NROFF,0, NULL },
+    { V('o',' '), 1,0, NULL },
+    { V('e',' '), 0,0, NULL },
+    { V('.','l'), 70,0,NULL },
+    { V('.','$'), 0,0, NULL },
+    { V('.','A'), NROFF,0, NULL },
+    { V('.','T'), 1-NROFF,0, NULL },
+    { V('.','V'), 1,0, NULL }, /* the me package tests for this */
+    { 0, 0, 0, NULL } };
+
+STRDEF standardstring[] = {
+    { V('R',' '), 1, "®", NULL },
+    { V('l','q'), 2, "``", NULL },
+    { V('r','q'), 2, "''", NULL },
+    { 0, 0, NULL, NULL}
+};
+
+
+STRDEF standardchar[] = {
+    { V('*','*'), 1, "*", NULL  },
+    { V('*','A'), 1, "A", NULL  },
+    { V('*','B'), 1, "B", NULL  },
+    { V('*','C'), 2, "Xi", NULL  },
+    { V('*','D'), 5, "Delta", NULL  },
+    { V('*','E'), 1, "E", NULL  },
+    { V('*','F'), 3, "Phi", NULL  },
+    { V('*','G'), 5, "Gamma", NULL  },
+    { V('*','H'), 5, "Theta", NULL  },
+    { V('*','I'), 1, "I", NULL  },
+    { V('*','K'), 1, "K", NULL  },
+    { V('*','L'), 6, "Lambda", NULL  },
+    { V('*','M'), 1, "M", NULL  },
+    { V('*','N'), 1, "N", NULL  },
+    { V('*','O'), 1, "O", NULL  },
+    { V('*','P'), 2, "Pi", NULL  },
+    { V('*','Q'), 3, "Psi", NULL  },
+    { V('*','R'), 1, "P", NULL  },
+    { V('*','S'), 5, "Sigma", NULL  },
+    { V('*','T'), 1, "T", NULL  },
+    { V('*','U'), 1, "Y", NULL  },
+    { V('*','W'), 5, "Omega", NULL  },
+    { V('*','X'), 1, "X", NULL  },
+    { V('*','Y'), 1, "H", NULL  },
+    { V('*','Z'), 1, "Z", NULL  },
+    { V('*','a'), 5, "alpha", NULL },
+    { V('*','b'), 4, "beta", NULL },
+    { V('*','c'), 2, "xi", NULL },
+    { V('*','d'), 5, "delta", NULL },
+    { V('*','e'), 7, "epsilon", NULL },
+    { V('*','f'), 3, "phi", NULL },
+    { V('*','g'), 5, "gamma", NULL },
+    { V('*','h'), 5, "theta", NULL },
+    { V('*','i'), 4, "iota", NULL },
+    { V('*','k'), 5, "kappa", NULL },
+    { V('*','l'), 6, "lambda", NULL },
+    { V('*','m'), 1, "µ", NULL  },
+    { V('*','n'), 2, "nu", NULL },
+    { V('*','o'), 1, "o", NULL },
+    { V('*','p'), 2, "pi", NULL },
+    { V('*','q'), 3, "psi", NULL },
+    { V('*','r'), 3, "rho", NULL },
+    { V('*','s'), 5, "sigma", NULL },
+    { V('*','t'), 3, "tau", NULL },
+    { V('*','u'), 7, "upsilon", NULL },
+    { V('*','w'), 5, "omega", NULL },
+    { V('*','x'), 3, "chi", NULL },
+    { V('*','y'), 3, "eta", NULL },
+    { V('*','z'), 4, "zeta", NULL },
+    { V('t','s'), 5, "sigma", NULL },
+    { V('+','-'), 1, "±", NULL  },
+    { V('1','2'), 1, "½", NULL  },
+    { V('1','4'), 1, "¼", NULL  },
+    { V('3','4'), 1, "¾", NULL  },
+    { V('F','i'), 3, "ffi", NULL  },
+    { V('F','l'), 3, "ffl", NULL  },
+    { V('a','a'), 1, "´", NULL  },
+    { V('a','p'), 1, "~", NULL  },
+    { V('b','r'), 1, "|", NULL  },
+    { V('b','u'), 1, "*", NULL  },
+    { V('b','v'), 1, "|", NULL  },
+    { V('c','i'), 1, "o", NULL  },
+    { V('c','o'), 1, "©", NULL  },
+    { V('c','t'), 1, "¢", NULL  },
+    { V('d','e'), 1, "°", NULL  },
+    { V('d','g'), 1, "+", NULL  },
+    { V('d','i'), 1, "÷", NULL  },
+    { V('e','m'), 1, "-", NULL  },
+    { V('e','m'), 3, "---", NULL },
+    { V('e','q'), 1, "=", NULL  },
+    { V('e','s'), 1, "Ø", NULL  },
+    { V('f','f'), 2, "ff", NULL  },
+    { V('f','i'), 2, "fi", NULL  },
+    { V('f','l'), 2, "fl", NULL  },
+    { V('f','m'), 1, "´", NULL  },
+    { V('g','a'), 1, "`", NULL  },
+    { V('h','y'), 1, "-", NULL  },
+    { V('l','c'), 2, "|¯", NULL  },
+    { V('l','f'), 2, "|_", NULL  },
+    { V('l','k'), 1, "<font size="+2">{</font>", NULL  },
+    { V('m','i'), 1, "-", NULL  },
+    { V('m','u'), 1, "×", NULL  },
+    { V('n','o'), 1, "¬", NULL  },
+    { V('o','r'), 1, "|", NULL  },
+    { V('p','l'), 1, "+", NULL  },
+    { V('r','c'), 2, "¯|", NULL  },
+    { V('r','f'), 2, "_|", NULL  },
+    { V('r','g'), 1, "®", NULL  },
+    { V('r','k'), 1, "<font size="+2">}</font>", NULL  },
+    { V('r','n'), 1, "¯", NULL  },
+    { V('r','u'), 1, "_", NULL  },
+    { V('s','c'), 1, "§", NULL  },
+    { V('s','l'), 1, "/", NULL  },
+    { V('s','q'), 2, "[]", NULL  },
+    { V('u','l'), 1, "_", NULL  },
+    { 0, 0, NULL, NULL  }
+};
+
+/* default: print code */
+
+
+char eqndelimopen=0, eqndelimclose=0;
+char escapesym='\\', nobreaksym='\'', controlsym='.', fieldsym=0, padsym=0;
+
+char *buffer=NULL;
+int buffpos=0, buffmax=0;
+int scaninbuff=0;
+int itemdepth=0;
+int dl_set[20]= { 0 };
+int still_dd=0;
+int tabstops[20] = { 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96 };
+int maxtstop=12;
+int curpos=0;
+
+extern char *scan_troff(char *c, int san, char **result);
+
+static char **argument=NULL;
+
+static char charb[3];
+
+void print_sig(void)
+{
+    char datbuf[500];
+    struct tm *timetm;
+    time_t clock;
+    datbuf[0]='\0';
+#ifdef TIMEFORMAT
+    clock=time(NULL);
+    timetm=gmtime(&amp;clock);
+    strftime(datbuf,500,TIMEFORMAT, timetm);
+#endif
+    printf(signature, datbuf);
+}
+
+char *expand_char(int nr)
+{
+  STRDEF *h;
+  h=chardef;
+  if (!nr) return NULL;
+  while (h)
+      if (h-&gt;nr==nr) {
+	  curpos+=h-&gt;slen;
+	  return h-&gt;st;
+      } else
+	  h=h-&gt;next;
+  charb[0]=nr/256;
+  charb[1]=nr%256;
+  charb[2]='\0';
+  curpos+=2;
+  return charb;
+}
+
+char *expand_string(int nr)
+{
+  STRDEF *h=strdef;
+  if (!nr) return NULL;
+  while (h)
+      if (h-&gt;nr==nr) {
+	  curpos+=h-&gt;slen;
+	  return h-&gt;st;
+    } else
+	h=h-&gt;next;
+  return NULL;
+}
+
+
+char outbuffer[1024];
+int obp=0;
+int no_newline_output=0;
+int newline_for_fun=0;
+int output_possible=0;
+int out_length=0;
+
+void add_links(char *c)
+{
+    /*
+    ** Add the links to the output.
+    ** At the moment the following are recognized:
+    **
+    ** name(*)                 -&gt; ../man?/name.*
+    ** method://string         -&gt; method://string
+    ** www.host.name           -&gt; http://www.host.name
+    ** ftp.host.name           -&gt; ftp://ftp.host.name
+    ** name@host               -&gt; mailto:name@host
+    ** <name.h>                -&gt; file:/usr/include/name.h   (guess)
+    **
+    ** Other possible links to add in the future:
+    **
+    ** /dir/dir/file  -&gt; file:/dir/dir/file
+    */
+    int i,j,nr;
+    char *f, *g,*h;
+    char *idtest[6]; /* url, mailto, www, ftp, manpage */
+    out_length+=strlen(c);
+    /* search for (section) */
+    nr=0;
+    idtest[0]=strstr(c+1,"://");
+    idtest[1]=strchr(c+1,'@');
+    idtest[2]=strstr(c,"www.");
+    idtest[3]=strstr(c,"ftp.");
+    idtest[4]=strchr(c+1,'(');
+    idtest[5]=strstr(c+1,".h&gt;");
+    for (i=0; i&lt;6; i++) nr += (idtest[i]!=NULL);
+    while (nr) {
+	j=-1;
+	for (i=0; i&lt;6; i++)
+	    if (idtest[i] &amp;&amp; (j&lt;0 || idtest[i]<idtest[j])) j="i;" +="" switch="" (j)="" {="" case="" 5:="" *="" <name.h=""> */
+	    f=idtest[5];
+	    h=f+2;
+	    g=f;
+	    while (g&gt;c &amp;&amp; g[-1]!=';') g--;
+	    if (g!=c) {
+		char t;
+		t=*g;
+		*g='\0';
+		printf("%s",c);
+		*g=t;*h='\0';
+		printf("<a href="\&quot;file:/usr/include/%s\&quot;">%s</a>&gt;", g,g);
+		c=f+6;
+	    } else {
+		f[5]='\0';
+		printf("%s",c);
+		f[5]=';';
+		c=f+5;
+	    }
+	    break;
+	case 4: /* manpage */
+	    f=idtest[j];
+	    /* check section */
+	    g=strchr(f,')');
+	    if (g &amp;&amp; f-g&lt;6 &amp;&amp; (isalnum(f[-1]) || f[-1]=='&gt;') &amp;&amp;
+		((isdigit(f[1]) &amp;&amp; f[1]!='0' &amp;&amp;
+		  (f[2]==')' || (isalpha(f[2]) &amp;&amp; f[3]==')') || f[2]=='X')) ||
+		 (f[2]==')' &amp;&amp; (f[1]=='n' || f[1]=='l')))) {
+		/* this might be a link */
+		h=f-1;
+		/* skip html makeup */
+		while (h&gt;c &amp;&amp; *h=='&gt;') {
+		    while (h!=c &amp;&amp; *h!='&lt;') h--;
+		    if (h!=c) h--;
+		}
+		if (isalnum(*h)) {
+		    char t,sec,subsec, *e;
+		    e=h+1;
+		    sec=f[1];
+		    subsec=f[2];
+		    if ((subsec=='X' &amp;&amp; f[3]!=')')|| subsec==')') subsec='\0';
+		    while (h&gt;c &amp;&amp; (isalnum(h[-1]) || h[-1]=='_' ||
+				    h[-1]=='-' || h[-1]=='.'))
+			h--;
+		    t=*h;
+		    *h='\0';
+		    printf("%s", c);
+		    *h=t;
+		    t=*e;
+		    *e='\0';
+		    if (subsec)
+			printf("<a href="\&quot;../man%c/%s.%c%c\&quot;">%s</a>",
+			       sec, h, sec, tolower(subsec), h);
+		    else
+			printf("<a href="\&quot;../man%c/%s.%c\&quot;">%s</a>",
+			       sec, h, sec, h);
+		    *e=t;
+		    c=e;
+		}
+	    }
+	    *f='\0';
+	    printf("%s", c);
+	    *f='(';
+	    idtest[4]=f-1;
+	    c=f;
+	    break; /* manpage */
+	case 3: /* ftp */
+	case 2: /* www */
+	    g=f=idtest[j];
+	    while (*g &amp;&amp; (isalnum(*g) || *g=='_' || *g=='-' || *g=='+' ||
+			  *g=='.')) g++;
+	    if (g[-1]=='.') g--;
+	    if (g-f&gt;4) {
+		char t;
+		t=*f; *f='\0';
+		printf("%s",c);
+		*f=t; t=*g;*g='\0';
+		printf("<a href="\&quot;%s://%s\&quot;">%s</a>", (j==3?"ftp":"http"),
+		       f,f);
+		*g=t;
+		c=g;
+	    } else {
+		f[3]='\0';
+		printf("%s",c);
+		c=f+3;
+		f[3]='.';
+	    }
+	    break;
+	case 1: /* mailto */
+	    g=f=idtest[1];
+	    while (g&gt;c &amp;&amp; (isalnum(g[-1]) || g[-1]=='_' || g[-1]=='-' ||
+			   g[-1]=='+' || g[-1]=='.' || g[-1]=='%')) g--;
+	    h=f+1;
+	    while (*h &amp;&amp; (isalnum(*h) || *h=='_' || *h=='-' || *h=='+' ||
+			  *h=='.')) h++;
+	    if (*h=='.') h--;
+	    if (h-f&gt;4 &amp;&amp; f-g&gt;1) {
+		char t;
+		t=*g;
+		*g='\0';
+		printf("%s",c);
+		*g=t;t=*h;*h='\0';
+		printf("<a href="\&quot;mailto:%s\&quot;">%s</a>",g,g);
+		*h=t;
+		c=h;
+	    } else {
+		*f='\0';
+		printf("%s",c);
+		*f='@';
+		idtest[1]=c;
+		c=f;
+	    }
+	    break;
+	case 0: /* url */
+	    g=f=idtest[0];
+	    while (g&gt;c &amp;&amp; isalpha(g[-1]) &amp;&amp; islower(g[-1])) g--;
+	    h=f+3;
+	    while (*h &amp;&amp; !isspace(*h) &amp;&amp; *h!='&lt;' &amp;&amp; *h!='&gt;' &amp;&amp; *h!='"' &amp;&amp;
+		   *h!='&amp;') h++;
+	    if (f-g&gt;2 &amp;&amp; f-g&lt;7 &amp;&amp; h-f&gt;3) {
+		char t;
+		t=*g;
+		*g='\0';
+		printf("%s", c);
+		*g=t; t=*h; *h='\0';
+		printf("<a href="\&quot;%s\&quot;">%s</a>", g,g);
+		*h=t;
+		c=h;
+	    } else {
+		f[1]='\0';
+		printf("%s", c);
+		f[1]='/';
+		c=f+1;
+	    }
+	    break;
+	default:
+	    break;
+	}
+	nr=0;
+	if (idtest[0] &amp;&amp; idtest[0]<c) idtest[0]="strstr(c+1,&quot;://&quot;);" +="" if="" (idtest[1]="" &&="" idtest[1]<c)="" idtest[1]="strchr(c+1,'@');" (idtest[2]="" idtest[2]<c)="" idtest[2]="strstr(c,&quot;www.&quot;);" (idtest[3]="" idtest[3]<c)="" idtest[3]="strstr(c,&quot;ftp.&quot;);" (idtest[4]="" idtest[4]<c)="" idtest[4]="strchr(c+1,'(');" (idtest[5]="" idtest[5]<c)="" idtest[5]="strstr(c+1,&quot;.h>&quot;);" for="" (i="0;" i<6;="" i++)="" nr="" }="" printf("%s",="" c);="" +}="" +int="" current_font="0;" current_size="0;" fillout="1;" +void="" out_html(char="" *c)="" +{="" (!c)="" return;="" (no_newline_output)="" {="" int="" i="0;" no_newline_output="1;" while="" (c[i])="" (!no_newline_output)="" c[i-1]="c[i];" (c[i]="='\n')" i++;="" (scaninbuff)="" (*c)="" (buffpos="">=buffmax) {
+	      char *h;
+	      h=realloc(buffer, buffmax*2);
+	      if (!h) return;
+	      buffer=h;
+	      buffmax=buffmax*2;
+	  }
+	  buffer[buffpos++]=*c++;
+      }
+  } else
+      if (output_possible) {
+	  while (*c) {
+	      outbuffer[obp++]=*c;
+	      if (*c=='\n' || obp&gt;1000) {
+		  outbuffer[obp]='\0';
+		  add_links(outbuffer);
+		  obp=0;
+	      }
+	      c++;
+	  }
+      }
+}
+
+#define FO0 ""
+#define FC0 ""
+#define FO1 "<i>"
+#define FC1 "</i>"
+#define FO2 "<b>"
+#define FC2 "</b>"
+#define FO3 "<tt>"
+#define FC3 "</tt>"
+
+char *switchfont[16] = { ""     , FC0 FO1, FC0 FO2, FC0 FO3,
+			 FC1 FO0, ""     , FC1 FO2, FC1 FO3,
+			 FC2 FO0, FC2 FO1, ""     , FC2 FO3,
+			 FC3 FO0, FC3 FO1, FC3 FO2, ""      };
+
+char *change_to_font(int nr)
+{
+  int i;
+  switch (nr) {
+  case '0': nr++;
+  case '1': case '2': case '3': case '4': nr=nr-'1'; break;
+  case V('C','W'): nr=3; break;
+  case 'L': nr=3; break;
+  case 'B': nr=2; break;
+  case 'I': nr=1; break;
+  case 'P': case 'R': nr=0; break;
+  case 0: case 1: case 2: case 3: break;
+  default: nr=0; break;
+  }
+  i= current_font*4+nr%4;
+  current_font=nr%4;
+  return switchfont[i];
+}
+
+static char sizebuf[200];
+
+char *change_to_size(int nr)
+{
+  int i;
+  switch (nr) {
+  case '0': case '1': case '2': case '3': case '4': case '5': case '6':
+  case '7': case '8': case '9': nr=nr-'0'; break;
+  case '\0': break;
+  default: nr=current_size+nr; if (nr&gt;9) nr=9; if (nr&lt; -9) nr=-9; break;
+  }
+  if (nr==current_size) return "";
+  i=current_font;
+  sizebuf[0]='\0';
+  strcat(sizebuf, change_to_font(0));
+  if (current_size) strcat(sizebuf, "");
+  current_size=nr;
+  if (nr) {
+    int l;
+    strcat(sizebuf, "<font size=");
+    l=strlen(sizebuf);
+    if (nr>0) sizebuf[l++]='+'; else sizebuf[l++]='-',nr=-nr;
+    sizebuf[l++]=nr+'0';
+    sizebuf[l++]='>';
+    sizebuf[l]='\0';
+  }
+  strcat(sizebuf, change_to_font(i));
+  return sizebuf;
+}
+
+int asint=0;
+int intresult=0;
+
+#define SKIPEOL while (*c &amp;&amp; *c++!='\n')
+
+static int skip_escape=0;
+static int single_escape=0;
+
+char *scan_escape(char *c)
+{
+    char *h=NULL;
+    char b[5];
+    INTDEF *intd;
+    int exoutputp,exskipescape;
+    int i,j;
+
+    intresult=0;
+    switch (*c) {
+    case 'e': h=" \\";="" curpos++;break;="" +="" case="" '0':="" '="" ':="" h="&nbsp;" ;curpos++;="" break;="" '|':="" ;="" '"':="" skipeol;="" c--;="" '$':="" if="" (argument)="" {="" c++;="" i="(*c" -'1');="" (!(h="argument[i]))" }="" 'z':="" (*c="='\\')" c="scan_escape(c+1);" c--;h="" else="" b[0]="*c;" b[1]="\0" 'k':="" c+="2;" '^':="" '!':="" '%':="" 'a':="" 'd':="" 'r':="" 'u':="" '\n':="" '&':="" '(':="" '*':="" *256+'="" ';="" 'f':="" !="(" )="" (!skip_escape)="" 's':="" j="0;i=0;" {j="-1;" c++;}="" (!j)="" while="" (isdigit(*c)="" &&="" (!i="" ||="" (!j="" i<4)))="" (i)="" 'n':="" switch="" (*c)="" '+':="" '-':="" default:="" ');="" intd="intdef;" (intd="" intd-="">nr!=i) intd=intd-&gt;next;
+	if (intd) {
+	    intd-&gt;val=intd-&gt;val+j*intd-&gt;incr;
+	    intresult=intd-&gt;val;
+	} else {
+	    switch (i) {
+	    case V('.','s'): intresult=current_size; break;
+	    case V('.','f'): intresult=current_font; break;
+	    default: intresult=0; break;
+	    }
+	}
+	h="";
+	break;
+    case 'w':
+	c++;
+	i=*c;
+	c++;
+	exoutputp=output_possible;
+	exskipescape=skip_escape;
+	output_possible=0;
+	skip_escape=1;
+	j=0;
+	while (*c!=i) {
+	    j++;
+	    if (*c==escapesym) c=scan_escape(c+1); else c++;
+	}
+	output_possible=exoutputp;
+	skip_escape=exskipescape;
+	intresult=j;
+	break;
+    case 'l': h="</font></c)></idtest[j]))></name.h></p><hr><font size=");
+    l=strlen(sizebuf);
+    if (nr>0) sizebuf[l++]='+'; else sizebuf[l++]='-',nr=-nr;
+    sizebuf[l++]=nr+'0';
+    sizebuf[l++]='>';
+    sizebuf[l]='\0';
+  }
+  strcat(sizebuf, change_to_font(i));
+  return sizebuf;
+}
+
+int asint=0;
+int intresult=0;
+
+#define SKIPEOL while (*c &amp;&amp; *c++!='\n')
+
+static int skip_escape=0;
+static int single_escape=0;
+
+char *scan_escape(char *c)
+{
+    char *h=NULL;
+    char b[5];
+    INTDEF *intd;
+    int exoutputp,exskipescape;
+    int i,j;
+
+    intresult=0;
+    switch (*c) {
+    case 'e': h=" \\";="" curpos++;break;="" +="" case="" '0':="" '="" ':="" h="&nbsp;" ;curpos++;="" break;="" '|':="" ;="" '"':="" skipeol;="" c--;="" '$':="" if="" (argument)="" {="" c++;="" i="(*c" -'1');="" (!(h="argument[i]))" }="" 'z':="" (*c="='\\')" c="scan_escape(c+1);" c--;h="" else="" b[0]="*c;" b[1]="\0" 'k':="" c+="2;" '^':="" '!':="" '%':="" 'a':="" 'd':="" 'r':="" 'u':="" '\n':="" '&':="" '(':="" '*':="" *256+'="" ';="" 'f':="" !="(" )="" (!skip_escape)="" 's':="" j="0;i=0;" {j="-1;" c++;}="" (!j)="" while="" (isdigit(*c)="" &&="" (!i="" ||="" (!j="" i<4)))="" (i)="" 'n':="" switch="" (*c)="" '+':="" '-':="" default:="" ');="" intd="intdef;" (intd="" intd-="">"; curpos=0;
+    case 'b':
+    case 'v':
+    case 'x':
+    case 'o':
+    case 'L':
+    case 'h':
+	c++;
+	i=*c;
+	c++;
+	exoutputp=output_possible;
+	exskipescape=skip_escape;
+	output_possible=0;
+	skip_escape=1;
+	while (*c != i)
+	    if (*c==escapesym) c=scan_escape(c+1);
+	    else c++;
+	output_possible=exoutputp;
+	skip_escape=exskipescape;
+	break;
+    case 'c': no_newline_output=1; break;
+    case '{': newline_for_fun++; h="";break;
+    case '}': if (newline_for_fun) newline_for_fun--; h="";break;
+    case 'p': h="<br>\n";curpos=0; break;
+    case 't': h="\t";curpos=(curpos+8)&amp;0xfff8; break;
+    case '&lt;': h="&lt;";curpos++; break;
+    case '&gt;': h="&gt;";curpos++; break;
+    case '\\': if (single_escape) { c--; break;}
+    default: b[0]=*c; b[1]=0; h=b; curpos++; break;
+    }
+    c++;
+    if (!skip_escape) out_html(h);
+    return c;
+}
+
+typedef struct TABLEITEM TABLEITEM;
+
+struct TABLEITEM {
+    char *contents;
+    int size,align,valign,colspan,rowspan,font,vleft,vright,space,width;
+    TABLEITEM *next;
+};
+
+static TABLEITEM emptyfield = {NULL,0,0,0,1,1,0,0,0,0,NULL};
+typedef struct TABLEROW TABLEROW;
+
+struct TABLEROW {
+    TABLEITEM *first;
+    TABLEROW *prev, *next;
+};
+
+static char *tableopt[]= { "center", "expand", "box", "allbox", "doublebox",
+			   "tab", "linesize", "delim", NULL };
+static int tableoptl[] = { 6,6,3,6,9,3,8,5,0};
+
+
+static void clear_table(TABLEROW *table)
+{
+    TABLEROW *tr1,*tr2;
+    TABLEITEM *ti1,*ti2;
+
+    tr1=table;
+    while (tr1-&gt;prev) tr1=tr1-&gt;prev;
+    while (tr1) {
+	ti1=tr1-&gt;first;
+	while (ti1) {
+	    ti2=ti1-&gt;next;
+	    if (ti1-&gt;contents) free(ti1-&gt;contents);
+	    free(ti1);
+	    ti1=ti2;
+	}
+	tr2=tr1;
+	tr1=tr1-&gt;next;
+	free(tr2);
+    }
+}
+
+char *scan_expression(char *c, int *result);
+
+static char *scan_format(char *c, TABLEROW **result, int *maxcol)
+{
+    TABLEROW *layout, *currow;
+    TABLEITEM *curfield;
+    int i,j;
+    if (*result) {
+	clear_table(*result);
+    }
+    layout= currow=(TABLEROW*) malloc(sizeof(TABLEROW));
+    currow-&gt;next=currow-&gt;prev=NULL;
+    currow-&gt;first=curfield=(TABLEITEM*) malloc(sizeof(TABLEITEM));
+    *curfield=emptyfield;
+    while (*c &amp;&amp; *c!='.') {
+	switch (*c) {
+	case 'C': case 'c': case 'N': case 'n':
+	case 'R': case 'r': case 'A': case 'a':
+	case 'L': case 'l': case 'S': case 's':
+	case '^': case '_':
+	    if (curfield-&gt;align) {
+		curfield-&gt;next=(TABLEITEM*)malloc(sizeof(TABLEITEM));
+		curfield=curfield-&gt;next;
+		*curfield=emptyfield;
+	    }
+	    curfield-&gt;align=toupper(*c);
+	    c++;
+	    break;
+	case 'i': case 'I': case 'B': case 'b':
+	    curfield-&gt;font = toupper(*c);
+	    c++;
+	    break;
+	case 'f': case 'F':
+	    c++;
+	    curfield-&gt;font = toupper(*c);
+	    c++;
+	    if (!isspace(*c)) c++;
+	    break;
+	case 't': case 'T': curfield-&gt;valign='t'; c++; break;
+	case 'p': case 'P':
+	    c++;
+	    i=j=0;
+	    if (*c=='+') { j=1; c++; }
+	    if (*c=='-') { j=-1; c++; }
+	    while (isdigit(*c)) i=i*10+(*c++)-'0';
+	    if (j) curfield-&gt;size= i*j; else curfield-&gt;size=j-10;
+	    break;
+	case 'v': case 'V':
+	case 'w': case 'W':
+	    c=scan_expression(c+2,&amp;curfield-&gt;width);
+	    break;
+	case '|':
+	    if (curfield-&gt;align) curfield-&gt;vleft++;
+	    else curfield-&gt;vright++;
+	    c++;
+	    break;
+	case 'e': case 'E':
+	    c++;
+	    break;
+	case '0': case '1': case '2': case '3': case '4':
+	case '5': case '6': case '7': case '8': case '9':
+	    i=0;
+	    while (isdigit(*c)) i=i*10+(*c++)-'0';
+	    curfield-&gt;space=i;
+	    break;
+	case ',': case '\n':
+	    currow-&gt;next=(TABLEROW*)malloc(sizeof(TABLEROW));
+	    currow-&gt;next-&gt;prev=currow;
+	    currow=currow-&gt;next;
+	    currow-&gt;next=NULL;
+	    curfield=currow-&gt;first=(TABLEITEM*)malloc(sizeof(TABLEITEM));
+	    *curfield=emptyfield;
+	    c++;
+	    break;
+	default:
+	    c++;
+	    break;
+	}
+    }
+    if (*c=='.') while (*c++!='\n');
+    *maxcol=0;
+    currow=layout;
+    while (currow) {
+	curfield=layout-&gt;first;
+	i=0;
+	while (curfield) {
+	    i++;
+	    curfield=curfield-&gt;next;
+	}
+	if (i&gt;*maxcol) *maxcol=i;
+	currow=currow-&gt;next;
+    }
+    *result=layout;
+    return c;
+}
+
+TABLEROW *next_row(TABLEROW *tr)
+{
+    if (tr-&gt;next) {
+	tr=tr-&gt;next;
+	if (!tr-&gt;next) next_row(tr);
+	return tr;
+    } else {
+	TABLEITEM *ti, *ti2;
+	tr-&gt;next=(TABLEROW*)malloc(sizeof(TABLEROW));
+	tr-&gt;next-&gt;prev=tr;
+	ti=tr-&gt;first;
+	tr=tr-&gt;next;
+	tr-&gt;next=NULL;
+	if (ti) tr-&gt;first=ti2=(TABLEITEM*) malloc(sizeof(TABLEITEM));
+	else tr-&gt;first=ti2=NULL;
+	while (ti!=ti2) {
+	    *ti2=*ti;
+	    ti2-&gt;contents=NULL;
+	    if ((ti=ti-&gt;next)) {
+		ti2-&gt;next=(TABLEITEM*) malloc(sizeof(TABLEITEM));
+	    }
+	    ti2=ti2-&gt;next;
+	}
+	return tr;
+    }
+}
+
+char itemreset[20]="\\fR\\s0";
+
+char *scan_table(char *c)
+{
+    char *t, *h, *g;
+    int center=0, expand=0, box=0, border=0, linesize=1;
+    int i,j,maxcol=0, finished=0;
+    int oldfont, oldsize,oldfillout;
+    char itemsep='\t';
+    TABLEROW *layout=NULL, *currow, *ftable;
+    TABLEITEM *curfield;
+    while (*c++!='\n');
+    h=c;
+    if (*h=='.') return c-1;
+    oldfont=current_font;
+    oldsize=current_size;
+    oldfillout=fillout;
+    out_html(change_to_font(0));
+    out_html(change_to_size(0));
+    if (!fillout) {
+	fillout=1;
+	out_html("</font></isindex></sys></time.h></sys></ctype.h></dirent.h></sys></string.h></stdlib.h></stdio.h></pre><font size=");
+    l=strlen(sizebuf);
+    if (nr>0) sizebuf[l++]='+'; else sizebuf[l++]='-',nr=-nr;
+    sizebuf[l++]=nr+'0';
+    sizebuf[l++]='>';
+    sizebuf[l]='\0';
+  }
+  strcat(sizebuf, change_to_font(i));
+  return sizebuf;
+}
+
+int asint=0;
+int intresult=0;
+
+#define SKIPEOL while (*c &amp;&amp; *c++!='\n')
+
+static int skip_escape=0;
+static int single_escape=0;
+
+char *scan_escape(char *c)
+{
+    char *h=NULL;
+    char b[5];
+    INTDEF *intd;
+    int exoutputp,exskipescape;
+    int i,j;
+
+    intresult=0;
+    switch (*c) {
+    case 'e': h=" \\";="" curpos++;break;="" +="" case="" '0':="" '="" ':="" h="&nbsp;" ;curpos++;="" break;="" '|':="" ;="" '"':="" skipeol;="" c--;="" '$':="" if="" (argument)="" {="" c++;="" i="(*c" -'1');="" (!(h="argument[i]))" }="" 'z':="" (*c="='\\')" c="scan_escape(c+1);" c--;h="" else="" b[0]="*c;" b[1]="\0" 'k':="" c+="2;" '^':="" '!':="" '%':="" 'a':="" 'd':="" 'r':="" 'u':="" '\n':="" '&':="" '(':="" '*':="" *256+'="" ';="" 'f':="" !="(" )="" (!skip_escape)="" 's':="" j="0;i=0;" {j="-1;" c++;}="" (!j)="" while="" (isdigit(*c)="" &&="" (!i="" ||="" (!j="" i<4)))="" (i)="" 'n':="" switch="" (*c)="" '+':="" '-':="" default:="" ');="" intd="intdef;" (intd="" intd-="">");
+    }
+    while (*h &amp;&amp; *h!='\n') h++;
+    if (h[-1]==';') {
+	/* scan table options */
+	while (c<h) {="" +="" while="" (isspace(*c))="" c++;="" for="" (i="0;" tableopt[i]="" &&="" strncmp(tableopt[i],c,tableoptl[i]);i++);="" c="c+tableoptl[i];" switch="" (i)="" case="" 0:="" center="1;" break;="" 1:="" expand="1;" 2:="" box="1;" 3:="" border="1;" 4:="" 5:="" (*c++!="(" );="" itemsep="*c++;" 6:="" linesize="0;" (isdigit(*c))="" 7:="" (*c!=")" )="" default:="" }="" *="" scan="" layout="" &maxcol);="" currow="layout;" next_row(currow);="" curfield="layout-">first;
+    i=0;
+    while (!finished) {
+	/* search item */
+	h=c;
+	if ((*c=='_' || *c=='=') &amp;&amp; (c[1]==itemsep || c[1]=='\n')) {
+	    if (c[-1]=='\n' &amp;&amp; c[1]=='\n') {
+		if (currow-&gt;prev) {
+		    currow-&gt;prev-&gt;next=(TABLEROW*) malloc(sizeof(TABLEROW));
+		    currow-&gt;prev-&gt;next-&gt;next=currow;
+		    currow-&gt;prev-&gt;next-&gt;prev=currow-&gt;prev;
+		    currow-&gt;prev=currow-&gt;prev-&gt;next;
+		} else {
+		    currow-&gt;prev=layout=(TABLEROW*) malloc(sizeof(TABLEROW));
+		    currow-&gt;prev-&gt;prev=NULL;
+		    currow-&gt;prev-&gt;next=currow;
+		}
+		curfield=currow-&gt;prev-&gt;first=
+		    (TABLEITEM*) malloc(sizeof(TABLEITEM));
+		*curfield=emptyfield;
+		curfield-&gt;align=*c;
+		curfield-&gt;colspan=maxcol;
+		curfield=currow-&gt;first;
+		c=c+2;
+	    } else {
+		if (curfield) {
+		    curfield-&gt;align=*c;
+		    do {
+			curfield=curfield-&gt;next;
+		    } while (curfield &amp;&amp; curfield-&gt;align=='S');
+		}
+		if (c[1]=='\n') {
+		    currow=next_row(currow);
+		    curfield=currow-&gt;first;
+		}
+		c=c+2;
+	    }
+	} else if (*c=='T' &amp;&amp; c[1]=='{') {
+	    h=c+2;
+	    c=strstr(h,"\nT}");
+	    c++;
+	    *c='\0';
+	    g=NULL;
+	    scan_troff(h,0,&amp;g);
+	    scan_troff(itemreset, 0,&amp;g);
+	    *c='T';
+	    c+=3;
+	    if (curfield) {
+		curfield-&gt;contents=g;
+		do {
+		    curfield=curfield-&gt;next;
+		} while (curfield &amp;&amp; curfield-&gt;align=='S');
+	    } else
+		if (g) free(g);
+	    if (c[-1]=='\n') {
+		currow=next_row(currow);
+		curfield=currow-&gt;first;
+	    }
+	} else if (*c=='.' &amp;&amp; c[1]=='T' &amp;&amp; c[2]=='&amp;' &amp;&amp; c[-1]=='\n') {
+	    TABLEROW *hr;
+	    while (*c++!='\n');
+	    hr=currow;
+	    currow=currow-&gt;prev;
+	    hr-&gt;prev=NULL;
+	    c=scan_format(c,&amp;hr, &amp;i);
+	    hr-&gt;prev=currow;
+	    currow-&gt;next=hr;
+	    currow=hr;
+	    next_row(currow);
+	    curfield=currow-&gt;first;
+	} else if (*c=='.' &amp;&amp; c[1]=='T' &amp;&amp; c[2]=='E' &amp;&amp; c[-1]=='\n') {
+	    finished=1;
+	    while (*c++!='\n');
+	    if (currow-&gt;prev)
+		currow-&gt;prev-&gt;next=NULL;
+	    currow-&gt;prev=NULL;
+	    clear_table(currow);
+	} else if (*c=='.' &amp;&amp; c[-1]=='\n' &amp;&amp; !isdigit(c[1])) {
+	    /* skip troff request inside table (usually only .sp ) */
+	    while (*c++!='\n');
+	} else {
+	    h=c;
+	    while (*c &amp;&amp; (*c!=itemsep || c[-1]=='\\') &amp;&amp;
+		   (*c!='\n' || c[-1]=='\\')) c++;
+	    i=0;
+	    if (*c==itemsep) {i=1; *c='\n'; }
+	    if (h[0]=='\\' &amp;&amp; h[2]=='\n' &amp;&amp;
+		(h[1]=='_' || h[1]=='^')) {
+		if (curfield) {
+		    curfield-&gt;align=h[1];
+		    do {
+			curfield=curfield-&gt;next;
+		    } while (curfield &amp;&amp; curfield-&gt;align=='S');
+		}
+		h=h+3;
+	    } else {
+		g=NULL;
+		h=scan_troff(h,1,&amp;g);
+		scan_troff(itemreset,0,&amp;g);
+		if (curfield) {
+		    curfield-&gt;contents=g;
+		    do {
+			curfield=curfield-&gt;next;
+		    } while (curfield &amp;&amp; curfield-&gt;align=='S');
+		} else if (g) free(g);
+	    }
+	    if (i) *c=itemsep;
+	    c=h;
+	    if (c[-1]=='\n') {
+		currow=next_row(currow);
+		curfield=currow-&gt;first;
+	    }
+	}
+    }
+    /* calculate colspan and rowspan */
+    currow=layout;
+    while (currow-&gt;next) currow=currow-&gt;next;
+    while (currow) {
+	TABLEITEM *ti, *ti1=NULL, *ti2=NULL;
+	ti=currow-&gt;first;
+	if (currow-&gt;prev) ti1=currow-&gt;prev-&gt;first;
+	while (ti) {
+	    switch (ti-&gt;align) {
+	    case 'S':
+		if (ti2) {
+		    ti2-&gt;colspan++;
+		    if (ti2-&gt;rowspan<ti->rowspan) ti2-&gt;rowspan=ti-&gt;rowspan;
+		}
+		break;
+	    case '^':
+		if (ti1) ti1-&gt;rowspan++;
+	    default:
+		if (!ti2) ti2=ti;
+		else {
+		    do {
+			ti2=ti2-&gt;next;
+		    } while (ti2 &amp;&amp; curfield-&gt;align=='S');
+		}
+		break;
+	    }
+	    ti=ti-&gt;next;
+	    if (ti1) ti1=ti1-&gt;next;
+	}
+	currow=currow-&gt;prev;
+    }
+    /* produce html output */
+    if (center) out_html("<center>");
+    if (box==2) out_html("");
+	curfield=currow-&gt;first;
+	while (curfield) {
+	    if (curfield-&gt;align!='S' &amp;&amp; curfield-&gt;align!='^') {
+		out_html("<td"); +="" switch="" (curfield-="">align) {
+		case 'N':
+		    curfield-&gt;space+=4;
+		case 'R':
+		    out_html(" ALIGN=right");
+		    break;
+		case 'C':
+		    out_html(" ALIGN=center");
+		default:
+		    break;
+		}
+		if (!curfield-&gt;valign &amp;&amp; curfield-&gt;rowspan&gt;1)
+		    out_html(" VALIGN=center");
+		if (curfield-&gt;colspan&gt;1) {
+		    char buf[5];
+		    out_html(" COLSPAN=");
+		    sprintf(buf, "%i", curfield-&gt;colspan);
+		    out_html(buf);
+		}
+		if (curfield-&gt;rowspan&gt;1) {
+		    char buf[5];
+		    out_html(" ROWSPAN=");
+		    sprintf(buf, "%i", curfield-&gt;rowspan);
+		    out_html(buf);
+		}
+		j=j+curfield-&gt;colspan;
+		out_html("&gt;");
+		if (curfield-&gt;size) out_html(change_to_size(curfield-&gt;size));
+		if (curfield-&gt;font) out_html(change_to_font(curfield-&gt;font));
+		switch (curfield-&gt;align) {
+		case '=': out_html("<hr><hr>"); break;
+		case '_': out_html("<hr>"); break;
+		default:
+		    if (curfield-&gt;contents) out_html(curfield-&gt;contents);
+		    break;
+		}
+		if (curfield-&gt;space)
+		    for (i=0; i<curfield->space;i++) out_html("&nbsp;");
+		if (curfield-&gt;font) out_html(change_to_font(0));
+		if (curfield-&gt;size) out_html(change_to_size(0));
+		if (j&gt;=maxcol &amp;&amp; curfield-&gt;align&gt;'@' &amp;&amp; curfield-&gt;align!='_')
+		    out_html("<br>");
+		out_html("");
+	    }
+	    curfield=curfield-&gt;next;
+	}
+	out_html("</curfield-></td");>\n");
+	currow=currow-&gt;next;
+    }
+    if (box &amp;&amp; !border) out_html("<table border=""><tbody><tr><td>");
+    out_html("<table"); +="" if="" (box="" ||="" border)="" {="" out_html("="" border");="" (!border)=""></table");></td></tr><tr><td><table"); +="" if="" (expand)="" out_html("="" width="100%&quot;);" }="">\n");
+    currow=layout;
+    while (currow) {
+	j=0;
+	out_html("</table");></td></tr><tr valign="top"></tr></tbody></table>");
+    out_html("");
+    if (box==2) out_html("");
+    if (center) out_html("</center>\n");
+    else out_html("\n");
+    if (!oldfillout) out_html("<pre>");
+    fillout=oldfillout;
+    out_html(change_to_size(oldsize));
+    out_html(change_to_font(oldfont));
+    return c;
+}
+
+char *scan_expression(char *c, int *result)
+{
+    int value=0,value2,j=0,sign=1,opex=0;
+    char oper='c';
+
+    if (*c=='!') {
+	c=scan_expression(c+1, &amp;value);
+	value= (!value);
+    } else if (*c=='n') {
+	c++;
+	value=NROFF;
+    } else if (*c=='t') {
+	c++;
+	value=1-NROFF;
+    } else if (*c=='\'' || *c=='"' || *c&lt;' ' || (*c=='\\' &amp;&amp; c[1]=='(')) {
+	/* ?string1?string2?
+	** test if string1 equals string2.
+	*/
+	char *st1=NULL, *st2=NULL, *h;
+	char *tcmp=NULL;
+	char sep;
+	sep=*c;
+	if (sep=='\\') {
+	    tcmp=c;
+	    c=c+3;
+	}
+	c++;
+	h=c;
+	while (*c!= sep &amp;&amp; (!tcmp || strncmp(c,tcmp,4))) c++;
+	*c='\n';
+	scan_troff(h, 1, &amp;st1);
+	*c=sep;
+	if (tcmp) c=c+3;
+	c++;
+	h=c;
+	while (*c!=sep &amp;&amp; (!tcmp || strncmp(c,tcmp,4))) c++;
+	*c='\n';
+	scan_troff(h,1,&amp;st2);
+	*c=sep;
+	if (!st1 &amp;&amp; !st2) value=1;
+	else if (!st1 || !st2) value=0;
+	else value=(!strcmp(st1, st2));
+	if (st1) free(st1);
+	if (st2) free(st2);
+	if (tcmp) c=c+3;
+	c++;
+    } else {
+	while (*c &amp;&amp; !isspace(*c) &amp;&amp; *c!=')') {
+	    opex=0;
+	    switch (*c) {
+	    case '(':
+		c=scan_expression(c+1, &amp;value2);
+		value2=sign*value2;
+		opex=1;
+		break;
+	    case '.':
+	    case '0': case '1':
+	    case '2': case '3':
+	    case '4': case '5':
+	    case '6': case '7':
+	    case '8': case '9': {
+		int num=0,denum=1;
+		value2=0;
+		while (isdigit(*c)) value2=value2*10+((*c++)-'0');
+		if (*c=='.') {
+		    c++;
+		    while (isdigit(*c)) {
+			num=num*10+((*c++)-'0');
+			denum=denum*10;
+		    }
+		}
+		if (isalpha(*c)) {
+		    /* scale indicator */
+		    switch (*c) {
+		    case 'i': /* inch -&gt; 10pt */
+			value2=value2*10+(num*10+denum/2)/denum;
+			num=0;
+			break;
+		    default:
+			break;
+		    }
+		    c++;
+		}
+		value2=value2+(num+denum/2)/denum;
+		value2=sign*value2;
+		opex=1;
+		break;
+	    }
+	    case '\\':
+		c=scan_escape(c+1);
+		value2=intresult*sign;
+		if (isalpha(*c)) c++; /* scale indicator */
+		opex=1;
+		break;
+	    case '-':
+		if (oper) { sign=-1; c++; break; }
+	    case '&gt;':
+	    case '&lt;':
+	    case '+':
+	    case '/':
+	    case '*':
+	    case '%':
+	    case '&amp;':
+	    case '=':
+	    case ':':
+		if (c[1]=='=') oper=(*c++) +16; else oper=*c;
+		c++;
+		break;
+	    default: c++; break;
+	    }
+	    if (opex) {
+		sign=1;
+		switch (oper) {
+		case 'c': value=value2; break;
+		case '-': value=value-value2; break;
+		case '+': value=value+value2; break;
+		case '*': value=value*value2; break;
+		case '/': if (value2) value=value/value2; break;
+		case '%': if (value2) value=value%value2; break;
+		case '&lt;': value=(value<value2); break;="" +="" case="" '="">': value=(value&gt;value2); break;
+		case '&gt;'+16: value=(value&gt;=value2); break;
+		case '&lt;'+16: value=(value&lt;=value2); break;
+		case '=': case '='+16: value=(value==value2); break;
+		case '&amp;': value = (value &amp;&amp; value2); break;
+		case ':': value = (value || value2); break;
+		default: fprintf(stderr, "Unknown operator %c.\n", oper);
+		}
+		oper=0;
+	    }
+	}
+	if (*c==')') c++;
+    }
+    *result=value;
+    return c;
+}
+
+void trans_char(char *c, char s, char t)
+{
+    char *sl=c;
+    int slash=0;
+    while (*sl!='\n' || slash) {
+	if (!slash) {
+	    if (*sl==escapesym)
+		slash=1;
+	    else if (*sl==s)
+		*sl=t;
+	} else slash=0;
+	sl++;
+    }
+}
+
+char *fill_words(char *c, char *words[], int *n)
+{
+    char *sl=c;
+    int slash=0;
+    int skipspace=0;
+    *n=0;
+    words[*n]=sl;
+    while (*sl &amp;&amp; (*sl!='\n' || slash)) {
+	if (!slash) {
+	    if (*sl=='"') {
+		*sl='\a';
+		skipspace=!skipspace;
+	    } else if (*sl==escapesym)
+		slash=1;
+	    else if ((*sl==' ' || *sl=='\t') &amp;&amp; !skipspace) {
+		*sl='\n';
+		if (words[*n]!=sl) (*n)++;
+		words[*n]=sl+1;
+	    }
+	} else {
+	    if (*sl=='"') {
+		sl--;
+		*sl='\n';
+		if (words[*n]!=sl) (*n)++;
+		sl++;
+		while (*sl &amp;&amp; *sl !='\n') sl++;
+		words[*n]=sl;
+		sl--;
+	    }
+	    slash=0;
+	}
+	sl++;
+    }
+    if (sl!=words[*n]) (*n)++;
+    return sl;
+}
+
+char *abbrev_list[] = {
+    "GSBG", "Getting Started ",
+    "SUBG", "Customizing SunOS",
+    "SHBG", "Basic Troubleshooting",
+    "SVBG", "SunView User's Guide",
+    "MMBG", "Mail and Messages",
+    "DMBG", "Doing More with SunOS",
+    "UNBG", "Using the Network",
+    "GDBG", "Games, Demos &amp; Other Pursuits",
+    "CHANGE", "SunOS 4.1 Release Manual",
+    "INSTALL", "Installing SunOS 4.1",
+    "ADMIN", "System and Network Administration",
+    "SECUR", "Security Features Guide",
+    "PROM", "PROM User's Manual",
+    "DIAG", "Sun System Diagnostics",
+    "SUNDIAG", "Sundiag User's Guide",
+    "MANPAGES", "SunOS Reference Manual",
+    "REFMAN", "SunOS Reference Manual",
+    "SSI", "Sun System Introduction",
+    "SSO", "System Services Overview",
+    "TEXT", "Editing Text Files",
+    "DOCS", "Formatting Documents",
+    "TROFF", "Using <b>nroff</b> and <b>troff</b>",
+    "INDEX", "Global Index",
+    "CPG", "C Programmer's Guide",
+    "CREF", "C Reference Manual",
+    "ASSY", "Assembly Language Reference",
+    "PUL", "Programming Utilities and Libraries",
+    "DEBUG", "Debugging Tools",
+    "NETP", "Network Programming",
+    "DRIVER", "Writing Device Drivers",
+    "STREAMS", "STREAMS Programming",
+    "SBDK", "SBus Developer's Kit",
+    "WDDS", "Writing Device Drivers for the SBus",
+    "FPOINT", "Floating-Point Programmer's Guide",
+    "SVPG", "SunView 1 Programmer's Guide",
+    "SVSPG", "SunView 1 System Programmer's Guide",
+    "PIXRCT", "Pixrect Reference Manual",
+    "CGI", "SunCGI Reference Manual",
+    "CORE", "SunCore Reference Manual",
+    "4ASSY", "Sun-4 Assembly Language Reference",
+    "SARCH", "<font size="-1">SPARC</font> Architecture Manual",
+    "KR", "The C Programming Language",
+    NULL, NULL };
+
+char *lookup_abbrev(char *c)
+{
+    int i=0;
+
+    if (!c) return "";
+    while (abbrev_list[i] &amp;&amp; strcmp(c,abbrev_list[i])) i=i+2;
+    if (abbrev_list[i]) return abbrev_list[i+1];
+    else return c;
+}
+
+char *section_list[] = {
+    "1", "User Commands ",
+    "1C", "User Commands",
+    "1G", "User Commands",
+    "1S", "User Commands",
+    "1V", "User Commands ",
+    "2", "System Calls",
+    "2V", "System Calls",
+    "3", "C Library Functions",
+    "3C", "Compatibility Functions",
+    "3F", "Fortran Library Routines",
+    "3K", "Kernel VM Library Functions",
+    "3L", "Lightweight Processes Library",
+    "3M", "Mathematical Library",
+    "3N", "Network Functions",
+    "3R", "RPC Services Library",
+    "3S", "Standard I/O Functions",
+    "3V", "C Library Functions",
+    "3X", "Miscellaneous Library Functions",
+    "4", "Devices and Network Interfaces",
+    "4F", "Protocol Families",
+    "4I", "Devices and Network Interfaces",
+    "4M", "Devices and Network Interfaces",
+    "4N", "Devices and Network Interfaces",
+    "4P", "Protocols",
+    "4S", "Devices and Network Interfaces",
+    "4V", "Devices and Network Interfaces",
+    "5", "File Formats",
+    "5V", "File Formats",
+    "6", "Games and Demos",
+    "7", "Environments, Tables, and Troff Macros",
+    "7V", "Environments, Tables, and Troff Macros",
+    "8", "Maintenance Commands",
+    "8C", "Maintenance Commands",
+    "8S", "Maintenance Commands",
+    "8V", "Maintenance Commands",
+    "L", "Local Commands",
+/* for Solaris: 
+    "1", "User Commands",
+    "1B", "SunOS/BSD Compatibility Package Commands",
+    "1b", "SunOS/BSD Compatibility Package Commands",
+    "1C", "Communication Commands ",
+    "1c", "Communication Commands",
+    "1F", "FMLI Commands ",
+    "1f", "FMLI Commands",
+    "1G", "Graphics and CAD Commands ",
+    "1g", "Graphics and CAD Commands ",
+    "1M", "Maintenance Commands",
+    "1m", "Maintenance Commands",
+    "1S", "SunOS Specific Commands",
+    "1s", "SunOS Specific Commands",
+    "2", "System Calls",
+    "3", "C Library Functions",
+    "3B", "SunOS/BSD Compatibility Library Functions",
+    "3b", "SunOS/BSD Compatibility Library Functions",
+    "3C", "C Library Functions",
+    "3c", "C Library Functions",
+    "3E", "C Library Functions",
+    "3e", "C Library Functions",
+    "3F", "Fortran Library Routines",
+    "3f", "Fortran Library Routines",
+    "3G", "C Library Functions",
+    "3g", "C Library Functions",
+    "3I", "Wide Character Functions",
+    "3i", "Wide Character Functions",
+    "3K", "Kernel VM Library Functions",
+    "3k", "Kernel VM Library Functions",
+    "3L", "Lightweight Processes Library",
+    "3l", "Lightweight Processes Library",
+    "3M", "Mathematical Library",
+    "3m", "Mathematical Library",
+    "3N", "Network Functions",
+    "3n", "Network Functions",
+    "3R", "Realtime Library",
+    "3r", "Realtime Library",
+    "3S", "Standard I/O Functions",
+    "3s", "Standard I/O Functions",
+    "3T", "Threads Library",
+    "3t", "Threads Library",
+    "3W", "C Library Functions",
+    "3w", "C Library Functions",
+    "3X", "Miscellaneous Library Functions",
+    "3x", "Miscellaneous Library Functions",
+    "4", "File Formats",
+    "4B", "SunOS/BSD Compatibility Package File Formats",
+    "4b", "SunOS/BSD Compatibility Package File Formats",
+    "5", "Headers, Tables, and Macros",
+    "6", "Games and Demos",
+    "7", "Special Files",
+    "7B", "SunOS/BSD Compatibility Special Files",
+    "7b", "SunOS/BSD Compatibility Special Files",
+    "8", "Maintenance Procedures",
+    "8C", "Maintenance Procedures",
+    "8c", "Maintenance Procedures",
+    "8S", "Maintenance Procedures",
+    "8s", "Maintenance Procedures",
+    "9", "DDI and DKI",
+    "9E", "DDI and DKI Driver Entry Points",
+    "9e", "DDI and DKI Driver Entry Points",
+    "9F", "DDI and DKI Kernel Functions",
+    "9f", "DDI and DKI Kernel Functions",
+    "9S", "DDI and DKI Data Structures",
+    "9s", "DDI and DKI Data Structures",
+    "L", "Local Commands",
+*/
+    NULL, "Misc. Reference Manual Pages",
+    NULL, NULL
+};
+
+char *section_name(char *c)
+{
+    int i=0;
+
+    if (!c) return "";
+    while (section_list[i] &amp;&amp; strcmp(c,section_list[i])) i=i+2;
+    if (section_list[i+1]) return section_list[i+1];
+    else return c;
+}
+
+char manidx[20000];
+int subs=0;
+int mip=0;
+char label[5]="lbAA";
+
+void add_to_index(int level, char *item)
+{
+    char *c=NULL;
+    label[3]++;
+    if (label[3]&gt;'Z') {
+	label[3]='A';
+	label[2]++;
+    }
+    if (level != subs) {
+	if (subs) {
+	    strcpy(manidx+mip, "\n");
+	    mip+=6;
+	} else {
+	    strcpy(manidx+mip, "<dl>\n");
+	    mip+=5;
+	}
+    }
+    subs=level;
+    scan_troff(item, 1, &amp;c);
+    sprintf(manidx+mip, "<dt><a href="\&quot;#%s\&quot;">%s</a></dt><dd>\n", label, c);
+    if (c) free(c);
+    while (manidx[mip]) mip++;
+}
+
+char *skip_till_newline(char *c)
+{
+    int lvl=0;
+
+    while (*c &amp;&amp; *c!='\n' || lvl&gt;0) {
+	if (*c=='\\') {
+	    c++;
+	    if (*c=='}') lvl--; else if (*c=='{') lvl++;
+	}
+	c++;
+    }
+    c++;
+    if (lvl&lt;0 &amp;&amp; newline_for_fun) {
+	newline_for_fun = newline_for_fun+lvl;
+	if (newline_for_fun&lt;0) newline_for_fun=0;
+    }
+    return c;
+}
+
+int ifelseval=0;
+
+char *scan_request(char *c)
+{
+    int i,j,mode=0;
+    char *h;
+    char *wordlist[20];
+    int words;
+    char *sl;
+    STRDEF *owndef;
+    while (*c==' ' || *c=='\t') c++;
+    if (c[0]=='\n') return c+1;
+    if (c[1]=='\n') j=1; else j=2;
+    while (c[j]==' ' || c[j]=='\t') j++;
+    if (c[0]==escapesym) {
+	/* some pages use .\" .\$1 .\} */
+	/* .\$1 is too difficult/stuppid */
+	if (c[1]=='$') c=skip_till_newline(c);
+	else
+	    c = scan_escape(c+1);
+    } else {
+	i=V(c[0],c[1]);
+	switch (i) {
+	case V('a','b'):
+	    h=c+j;
+	    while (*h &amp;&amp; *h !='\n') h++;
+	    *h='\0';
+	    if (scaninbuff &amp;&amp; buffpos) {
+		buffer[buffpos]='\0';
+		printf("%s\n", buffer);
+	    }
+	    fprintf(stderr, "%s\n", c+2);
+	    exit(0);
+	    break;
+	case V('d','i'):
+	    {
+		STRDEF *de;
+		int oldcurpos=curpos;
+		c=c+j;
+		i=V(c[0],c[1]);
+		if (*c=='\n') { c++;break; }
+		while (*c &amp;&amp; *c!='\n') c++;
+		c++;
+		h=c;
+		while (*c &amp;&amp; strncmp(c,".di",3)) while (*c &amp;&amp; *c++!='\n');
+		*c='\0';
+		de=strdef;
+		while (de &amp;&amp; de-&gt;nr !=i) de=de-&gt;next;
+		if (!de) {
+		    de=(STRDEF*) malloc(sizeof(STRDEF));
+		    de-&gt;nr=i;
+		    de-&gt;slen=0;
+		    de-&gt;next=strdef;
+		    de-&gt;st=NULL;
+		    strdef=de;
+		} else {
+		    if (de-&gt;st) free(de-&gt;st);
+		    de-&gt;slen=0;
+		    de-&gt;st=NULL;
+		}
+		scan_troff(h,0,&amp;de-&gt;st);
+		*c='.';
+		while (*c &amp;&amp; *c++!='\n');
+		break;
+	    }
+	case V('d','s'):
+	    mode=1;
+	case V('a','s'):
+	    {
+		STRDEF *de;
+		int oldcurpos=curpos;
+		c=c+j;
+		i=V(c[0],c[1]);
+		j=0;
+		while (c[j] &amp;&amp; c[j]!='\n') j++;
+		if (j&lt;3) { c=c+j; break; }
+		if (c[1]==' ') c=c+1; else c=c+2;
+		while (isspace(*c)) c++;
+		if (*c=='"') c++;
+		de=strdef;
+		while (de &amp;&amp; de-&gt;nr != i) de=de-&gt;next;
+		single_escape=1;
+		curpos=0;
+		if (!de) {
+		    char *h;
+		    de=(STRDEF*) malloc(sizeof(STRDEF));
+		    de-&gt;nr=i;
+		    de-&gt;slen=0;
+		    de-&gt;next=strdef;
+		    de-&gt;st=NULL;
+		    strdef=de;
+		    h=NULL;
+		    c=scan_troff(c, 1, &amp;h);
+		    de-&gt;st=h;
+		    de-&gt;slen=curpos;
+		} else {
+		    if (mode) {
+			char *h=NULL;
+			c=scan_troff(c, 1, &amp;h);
+			free(de-&gt;st);
+			de-&gt;slen=0;
+			de-&gt;st=h;
+		    } else
+			c=scan_troff(c,1,&amp;de-&gt;st);
+		    de-&gt;slen+=curpos;
+		}
+		single_escape=0;
+		curpos=oldcurpos;
+	    }
+	    break;
+	case V('b','r'):
+	    if (still_dd) out_html("</dd><dd>");
+	    else out_html("<br>\n");
+	    curpos=0;
+	    c=c+j;
+	    if (c[0]==escapesym) { c=scan_escape(c+1); }
+	    c=skip_till_newline(c);break;
+	case V('c','2'):
+	    c=c+j;
+	    if (*c!='\n') { nobreaksym=*c; }
+	    else nobreaksym='\'';
+	    c=skip_till_newline(c);
+	    break;
+	case V('c','c'):
+	    c=c+j;
+	    if (*c!='\n') { controlsym=*c; }
+	    else controlsym='.';
+	    c=skip_till_newline(c);
+	    break;
+	case V('c','e'):
+	    c=c+j;
+	    if (*c=='\n') { i=1; }
+	    else {
+		i=0;
+		while ('0'&lt;=*c &amp;&amp; *c&lt;='9') {
+		    i=i*10+*c-'0';
+		    c++;
+		}
+	    }
+	    c=skip_till_newline(c);
+	    /* center next i lines */
+	    if (i&gt;0) {
+		out_html("<center>\n");
+		while (i &amp;&amp; *c) {
+		    char *line=NULL;
+		    c=scan_troff(c,1, &amp;line);
+		    if (line &amp;&amp; strncmp(line, "<br>", 4)) {
+			out_html(line);
+			out_html("<br>\n");
+			i--;
+		    }
+		}
+		out_html("</center>\n");
+		curpos=0;
+	    }
+	    break;
+	case V('e','c'):
+	    c=c+j;
+	    if (*c!='\n') { escapesym=*c; }
+	    else escapesym='\\';
+	    break;
+	    c=skip_till_newline(c);
+	case V('e','o'):
+	    escapesym='\0';
+	    c=skip_till_newline(c);
+	    break;
+	case V('e','x'):
+	    exit(0);
+	    break;
+	case V('f','c'):
+	    c=c+j;
+	    if  (*c=='\n') {
+		fieldsym=padsym='\0';
+	    } else {
+		fieldsym=c[0];
+		padsym=c[1];
+	    }
+	    c=skip_till_newline(c);
+	    break;
+	case V('f','i'):
+	    if (!fillout) {
+		out_html(change_to_font(0));
+		out_html(change_to_size('0'));
+		out_html("</dd></dl></value2);></pre>\n");
+	    }
+	    curpos=0;
+	    fillout=1;
+	    c=skip_till_newline(c);
+	    break;
+	case V('f','t'):
+	    c=c+j;
+	    if (*c=='\n') {
+		out_html(change_to_font(0));
+	    } else {
+		if (*c==escapesym) {
+		    int fn;
+		    c=scan_expression(c, &amp;fn);
+		    c--;
+		    out_html(change_to_font(fn));
+		} else {
+		    out_html(change_to_font(*c));
+		    c++;
+		}
+	    }
+	    c=skip_till_newline(c);
+	    break;
+	case V('e','l'):
+	    /* .el anything : else part of if else */
+	    if (ifelseval) {
+		c=c+j;
+		c[-1]='\n';
+		c=scan_troff(c,1,NULL);
+	    } else
+		c=skip_till_newline(c+j);
+	    break;
+	case V('i','e'):
+	    /* .ie c anything : then part of if else */	
+	case V('i','f'):
+	    /* .if c anything
+	     * .if !c anything
+	     * .if N anything
+	     * .if !N anything
+	     * .if 'string1'string2' anything
+	     * .if !'string1'string2' anything
+	     */
+	    c=c+j;
+	    c=scan_expression(c, &amp;i);
+	    ifelseval=!i;
+	    if (i) {
+		*c='\n';
+		c++;
+		c=scan_troff(c,1,NULL);
+	    } else
+		c=skip_till_newline(c);
+	    break;
+	case V('i','g'):
+	    {
+		char *endwith="..\n";
+		i=3;
+		c=c+j;
+		if (*c!='\n') {
+		    endwith=c-1;i=1;
+		    c[-1]='.';
+		    while (*c!='\n') c++,i++;
+		}
+		c++;
+		while (*c &amp;&amp; strncmp(c,endwith,i)) while (*c++!='\n');
+		while (*c++!='\n');
+		break;
+	    }
+	case V('n','f'):
+	    if (fillout) {
+		out_html(change_to_font(0));
+		out_html(change_to_size('0'));
+		out_html("<pre>\n");
+	    }
+	    curpos=0;
+	    fillout=0;
+	    c=skip_till_newline(c);
+	    break;
+	case V('p','s'):
+	    c=c+j;
+	    if (*c=='\n') {
+		out_html(change_to_size('0'));
+	    } else {
+		j=0;i=0;
+		if (*c=='-') { j= -1;c++; } else if (*c=='+') { j=1;c++;}
+		c=scan_expression(c, &amp;i);
+		if (!j) { j=1; if (i&gt;5) i=i-10; }
+		out_html(change_to_size(i*j));
+	    }
+	    c=skip_till_newline(c);
+	    break;
+	case V('s','p'):
+	    c=c+j;
+	    if (fillout) out_html("<p>"); else {
+		out_html(NEWLINE);
+		NEWLINE[0]='\n';
+	    }
+	    curpos=0;
+	    c=skip_till_newline(c);
+	    break;
+	case V('s','o'):
+	    {
+		FILE *f;
+		struct stat stbuf;
+		int l;char *buf;
+		char *name=NULL;
+		curpos=0;
+		c=c+j;
+		if (*c=='/') {
+		    h=c;
+		} else {
+		    h=c-3;
+		    h[0]='.';
+		    h[1]='.';
+		    h[2]='/';
+		}
+		while (*c!='\n') c++;
+		*c='\0';
+		scan_troff(h,1, &amp;name);
+		if (name[3]=='/') h=name+3; else h=name;
+		if (stat(h, &amp;stbuf)!=-1) l=stbuf.st_size;
+		buf = (char*) malloc((l+4)*sizeof(char));
+#if NOCGI
+                if (!out_length) {
+		    char *t,*s;
+		    t=strrchr(fname, '/');
+		    if (!t) t=fname;
+		    fprintf(stderr, "ln -s %s.html %s.html\n", h, t);
+		    s=strrchr(t, '.');if (!s) s=t;
+		    printf("<title> Manpage of %s</title>\n"
+			   "\n"
+			   "See the manpage for <a href="\&quot;%s.html\&quot;">%s</a>.\n"
+			   "\n",
+			   s, h, h);
+		} else
+#endif
+                {
+		    /* this works alright, except for section 3 */
+		    f=fopen(h,"r");
+		    if (!f || !buf || !l)
+			fprintf(stderr, "Unable to open or read file %s.\n",
+				h); 
+		    else {
+			i=fread(buf+1,1,l,f);
+			fclose(f);
+			buf[0]=buf[l]='\n';
+			buf[l+1]=buf[l+2]='\0';
+			scan_troff(buf+1,0,NULL);
+		    }
+		    if (buf) free(buf);
+		}
+		*c++='\n';
+		break;
+	    }
+	case V('t','a'):
+	    c=c+j;
+	    j=0;
+	    while (*c!='\n') {
+		sl=scan_expression(c, &amp;tabstops[j]);
+		if (*c=='-' || *c=='+') tabstops[j]+=tabstops[j-1];
+		c=sl;
+		while (*c==' ' || *c=='\t') c++;
+		j++;
+	    }
+	    maxtstop=j;
+	    curpos=0;
+	    break;
+	case V('t','i'):
+	    /*while (itemdepth || dl_set[itemdepth]) {
+		out_html("\n");
+		if (dl_set[itemdepth]) dl_set[itemdepth]=0;
+		else itemdepth--;
+	    }*/
+	    out_html("<br>\n");
+	    c=c+j;
+	    c=scan_expression(c, &amp;j);
+	    for (i=0; i<j; i++)="" out_html("&nbsp;");="" +="" curpos="j;" c="skip_till_newline(c);" break;="" case="" v('t','m'):="" h="c;" while="" (*c!="\n" )="" c++;="" *c="\0" ;="" fprintf(stderr,"%s\n",="" h);="" v('b','="" '):="" v('b','\n'):="" v('i','="" v('i','\n'):="" *="" parse="" one="" line="" in="" a="" certain="" font="" out_html(change_to_font(*c));="" trans_char(c,'"','\a');="" if="" (*c="='\n')" 1,="" null);="" out_html(change_to_font('r'));="" out_html(newline);="" (fillout)="" curpos++;="" else="" v('o','p'):="" groff="" manpages="" use="" this="" construction="" .op="" b="" :="" [="" <b="">a <i>b</i> ] */
+	    mode=1;
+	    c[0]='B'; c[1]='I';
+	    out_html(change_to_font('R'));
+	    out_html("[");
+	    curpos++;
+	case V('B','R'):
+	case V('B','I'):
+	case V('I','B'):
+	case V('I','R'):
+	case V('R','B'):
+	case V('R','I'):
+	    {
+		char font[2] = { c[0], c[1] };
+		c=c+j;
+		if (*c=='\n') c++;
+		sl=fill_words(c, wordlist, &amp;words);
+		c=sl+1;
+		/* .BR name (section)
+		** indicates a link. It will be added in the output routine.
+		*/
+		for (i=0; i<words; i++)="" {="" +="" if="" (mode)="" out_html("="" ");="" curpos++;="" }="" wordlist[i][-1]=" " ;="" out_html(change_to_font(font[i&1]));="" scan_troff(wordlist[i],1,null);="" out_html(change_to_font('r'));="" ]");="" curpos++;}="" out_html(newline);="" (!fillout)="" curpos="0;" else="" break;="" case="" v('d','t'):="" for="" (j="0;j<20;" j++)="" tabstops[j]="(j+1)*8;" maxtstop="20;" c="skip_till_newline(c);" v('i','p'):="" sl="fill_words(c+j," wordlist,="" &words);="" (!dl_set[itemdepth])="" out_html("<dl="" compact="">\n");
+		dl_set[itemdepth]=1;
+	    }
+	    out_html("</words;></j;></p><dt>");
+            if (words) {
+		scan_troff(wordlist[0], 1,NULL);
+	    }
+	    out_html("</dt><dd>");
+	    curpos=0;
+	    break;
+	case V('T','P'):
+	    if (!dl_set[itemdepth]) {
+		out_html("<dl compact="">\n");
+		dl_set[itemdepth]=1;
+	    }
+	    out_html("<dt>");
+	    c=skip_till_newline(c);
+	    /* somewhere a definition ends with '.TP' */
+	    if (!*c) still_dd=1; else {
+		c=scan_troff(c,1,NULL);
+		out_html("</dt><dd>");
+	    }
+	    curpos=0;
+	    break;
+	case V('I','X'):
+            /* general index */
+	    sl = fill_words(c+j, wordlist, &amp;words);
+	    c=sl+1;
+	    j=4;
+	    while (idxlabel[j]=='Z') idxlabel[j--]='A';
+	    idxlabel[j]++;
+#ifdef MAKEINDEX
+            fprintf(idxfile, "%s@%s@", fname, idxlabel);
+	    for (j=0; j<words; j++)="" {="" +="" h="NULL;" scan_troff(wordlist[j],="" 1,="" &h);="" fprintf(idxfile,="" "_\b@%s",="" h);="" free(h);="" }="" fprintf(idxfile,"\n");="" +#endif="" out_html("<a="" name="\&quot;&quot;);" out_html(idxlabel);="" *="" this="" will="" not="" work="" in="" mosaic="" (due="" to="" a="" bug).="" **="" adding="" '&nbsp;'="" between="" '="">' and '&lt;' solves it, but creates
+	    ** some space. A normal space does not work.
+	    */
+	    out_html("\"&gt;");
+	    break;
+	case V('L','P'):
+	case V('P','P'):
+	    if (dl_set[itemdepth]) {
+		out_html("</words;></dd></dl>\n");
+		dl_set[itemdepth]=0;
+	    }
+	    if (fillout) out_html("<p>\n"); else {
+		out_html(NEWLINE);
+		NEWLINE[0]='\n';
+	    }
+	    curpos=0;
+	    c=skip_till_newline(c);
+	    break;
+	case V('H','P'):
+	    if (!dl_set[itemdepth]) {
+		out_html("</p><dl compact="">");
+		dl_set[itemdepth]=1;
+	    }
+	    out_html("<dt>\n");
+	    still_dd=1;
+	    c=skip_till_newline(c);
+	    curpos=0;
+	    break;
+	case V('P','D'): c=skip_till_newline(c); break;
+	case V('R','S'):
+	    sl=fill_words(c+j, wordlist, &amp;words);
+	    j=1;
+	    if (words&gt;0) scan_expression(wordlist[0], &amp;j);
+	    if (j&gt;=0) {
+		itemdepth++;
+		dl_set[itemdepth]=0;
+		out_html("<dl compact=""><dt></dt><dd>");
+		c=skip_till_newline(c);
+		curpos=0;
+		break;
+	    }
+	case V('R','E'):
+	    if (itemdepth) {
+		if (dl_set[itemdepth]) out_html("</dd></dl>");
+		out_html("</dt></dl>\n");
+		itemdepth--;
+	    }
+	    c=skip_till_newline(c);
+	    curpos=0;
+	    break;
+	case V('S','B'):
+	    out_html(change_to_size(-1));
+	    out_html(change_to_font('B'));
+	    c=scan_troff(c+j, 1, NULL);
+	    out_html(change_to_font('R'));
+	    out_html(change_to_size('0'));
+	    break;
+	case V('S','M'):
+	    c=c+j;
+	    if (*c=='\n') c++;
+	    out_html(change_to_size(-1));
+	    trans_char(c,'"','\a');
+	    c=scan_troff(c,1,NULL);
+	    out_html(change_to_size('0'));
+	    break;
+	case V('S','S'):
+	    mode=1;
+	case V('S','H'):
+	    c=c+j;
+	    if (*c=='\n') c++;
+	    while (itemdepth || dl_set[itemdepth]) {
+		out_html("\n");
+		if (dl_set[itemdepth]) dl_set[itemdepth]=0;
+		else itemdepth--;
+	    }
+	    out_html(change_to_font(0));
+	    out_html(change_to_size(0));
+	    if (!fillout) {
+		fillout=1;
+		out_html("</dd></pre>");
+	    }
+	    trans_char(c,'"', '\a');
+	    add_to_index(mode, c);
+	    out_html("<a name="\&quot;&quot;);" +="" out_html(label);="" *="" &nbsp;="" for="" mosaic="" users="" if="" (mode)="" out_html("\"="">&nbsp;</a>\n<h3>");
+	    else out_html("\"&gt;&nbsp;\n</h3><h2>");
+	    c=scan_troff(c,1,NULL);
+	    if (mode) out_html("</h2>\n");
+	    else out_html("\n");
+	    curpos=0;
+	    break;
+	case V('T','S'):
+	    c=scan_table(c);
+	    break;
+	case V('T','H'):
+	    if (!output_possible) {
+		sl = fill_words(c+j, wordlist, &amp;words);
+		if (words&gt;1) {
+		    for (i=1; i<words; i++)="" wordlist[i][-1]="\0" ;="" +="" *sl="\0" output_possible="1;" out_html("<html=""><title>Manpage of ");
+		    out_html(wordlist[0]);
+		    out_html("</title>\n\n<h1>");
+		    out_html(wordlist[0]);
+		    out_html("</h1>\nSection: ");
+		    if (words&gt;4) out_html(wordlist[4]);
+		    else
+			out_html(section_name(wordlist[1]));
+		    out_html(" (");
+		    out_html(wordlist[1]);
+		    if (words&gt;2) {
+			out_html(")<br>Updated: ");
+			scan_troff(wordlist[2], 1, NULL);
+		    } else out_html(")");
+		    out_html("<br><a href="\&quot;#index\&quot;">Index</a>\n");
+		    *sl='\n';
+		    out_html("<hr>\n");
+		}
+		c=sl+1;
+	    } else c=skip_till_newline(c);
+	    curpos=0;
+	    break;
+	case V('T','X'):
+	    sl=fill_words(c+j, wordlist, &amp;words);
+	    *sl='\0';
+	    out_html(change_to_font('I'));
+	    if (words&gt;1) wordlist[1][-1]='\0';
+	    c=lookup_abbrev(wordlist[0]);
+	    curpos+=strlen(c);
+	    out_html(c);
+	    out_html(change_to_font('R'));
+	    if (words&gt;1)
+		out_html(wordlist[1]);
+	    *sl='\n';
+	    c=sl+1;
+	    break;
+	case V('r','m'):
+            /* .rm xx : Remove request, macro or string */
+	case V('r','n'):
+            /* .rn xx yy : Rename request, macro or string xx to yy */
+	    {
+		STRDEF *de;
+		c=c+j;
+		i=V(c[0],c[1]);
+		c=c+2;
+		while (isspace(*c) &amp;&amp; *c!='\n') c++;
+		j=V(c[0],c[1]);
+		while (*c &amp;&amp; *c!='\n') c++;
+		c++;
+		de=strdef;
+		while (de &amp;&amp; de-&gt;nr!=j) de=de-&gt;next;
+		if (de) {
+		    if (de-&gt;st) free(de-&gt;st);
+		    de-&gt;nr=0;
+		}
+		de=strdef;
+		while (de &amp;&amp; de-&gt;nr!=i) de=de-&gt;next;
+		if (de) de-&gt;nr=j;
+		break;
+	    }
+	case V('n','x'):
+            /* .nx filename : next file. */
+	case V('i','n'):
+            /* .in +-N : Indent */
+	    c=skip_till_newline(c);
+	    break;
+	case V('n','r'):
+            /* .nr R +-N M: define and set number register R by +-N;
+	    **  auto-increment by M
+	    */
+	    {
+		INTDEF *intd;
+		c=c+j;
+		i=V(c[0],c[1]);
+		c=c+2;
+		intd=intdef;
+		while (intd &amp;&amp; intd-&gt;nr!=i) intd=intd-&gt;next;
+		if (!intd) {
+		    intd = (INTDEF*) malloc(sizeof(INTDEF));
+		    intd-&gt;nr=i;
+		    intd-&gt;val=0;
+		    intd-&gt;incr=0;
+		    intd-&gt;next=intdef;
+		    intdef=intd;
+		}
+		while (*c==' ' || *c=='\t') c++;
+		c=scan_expression(c,&amp;intd-&gt;val);
+		if (*c!='\n') {
+		    while (*c==' ' || *c=='\t') c++;
+		    c=scan_expression(c,&amp;intd-&gt;incr);
+		}
+		c=skip_till_newline(c);
+		break;
+	    }
+	case V('a','m'):
+            /* .am xx yy : append to a macro. */
+            /* define or handle as .ig yy */
+	    mode=1;
+	case V('d','e'):
+            /* .de xx yy : define or redefine macro xx; end at .yy (..) */
+            /* define or handle as .ig yy */
+	    {
+		STRDEF *de;
+		int olen=0;
+		c=c+j;
+		sl=fill_words(c, wordlist, &amp;words);
+		i=V(c[0],c[1]);j=2;
+		if (words==1) wordlist[1]=".."; else {
+		    wordlist[1]--;
+		    wordlist[1][0]='.';
+		    j=3;
+		}
+		c=sl+1;
+		sl=c;
+		while (*c &amp;&amp; strncmp(c,wordlist[1],j)) c=skip_till_newline(c);
+		de=defdef;
+		while (de &amp;&amp; de-&gt;nr!= i) de=de-&gt;next;
+		if (mode &amp;&amp; de) olen=strlen(de-&gt;st);
+		j=olen+c-sl;
+		h= (char*) malloc((j*2+4)*sizeof(char));
+		if (h) {
+		    for (j=0; j<olen; j++)="" +="" h[j]="de-">st[j];
+		    if (!j || h[j-1]!='\n')
+			h[j++]='\n';
+		    while (sl!=c) {
+			if (sl[0]=='\\' &amp;&amp; sl[1]=='\\') {
+			    h[j++]='\\'; sl++;
+			} else
+			    h[j++]=*sl;
+			sl++;
+		    }
+		    h[j]='\0';
+		    if (de) {
+			if (de-&gt;st) free(de-&gt;st);
+			de-&gt;st=h;
+		    } else {
+			de = (STRDEF*) malloc(sizeof(STRDEF));
+			de-&gt;nr=i;
+			de-&gt;next=defdef;
+			de-&gt;st=h;
+			defdef=de;
+		    }
+		}
+	    }
+	    c=skip_till_newline(c);
+	    break;
+	default:
+            /* search macro database of self-defined macros */
+	    owndef = defdef;
+	    while (owndef &amp;&amp; owndef-&gt;nr!=i) owndef=owndef-&gt;next;
+	    if (owndef) {
+		char **oldargument;
+		int deflen;
+		int onff;
+		sl=fill_words(c+j, wordlist, &amp;words);
+		c=sl+1;
+		*sl='\0';
+		for (i=1;i<words; i++)="" wordlist[i][-1]="\0" ;="" +="" for="" (i="0;" i<words;="" {="" char="" *h="NULL;" scan_troff(wordlist[i],1,&h);="" wordlist[i]="h;" }="" deflen="strlen(owndef-">st);
+		for (i=0; owndef-&gt;st[deflen+2+i]=owndef-&gt;st[i]; i++);
+		oldargument=argument;
+		argument=wordlist;
+		onff=newline_for_fun;
+		scan_troff(owndef-&gt;st+deflen+2, 0, NULL);
+		newline_for_fun=onff;
+		argument=oldargument;
+		for (i=0; i<words; i++)="" if="" (wordlist[i])="" free(wordlist[i]);="" +="" *sl="\n" ;="" }="" else="" c="skip_till_newline(c);" break;="" (fillout)="" {="" out_html(newline);="" curpos++;="" newline[0]="\n" return="" c;="" +}="" +void="" flush(void)="" +{="" +static="" int="" contained_tab="0;" +char="" *scan_troff(char="" *c,="" san,="" char="" **result)="" *="" san="" :="" stop="" at="" newline="" *h;="" intbuff[500];="" ibp="0;" i;="" +#define="" flushibp="" (ibp)="" intbuff[ibp]="0;" out_html(intbuff);="" *exbuffer;="" exbuffpos,="" exbuffmax,="" exscaninbuff,="" exnewline_for_fun;="" usenbsp="0;" exbuffer="buffer;" exbuffpos="buffpos;" exbuffmax="buffmax;" exnewline_for_fun="newline_for_fun;" exscaninbuff="scaninbuff;" newline_for_fun="0;" (result)="" (*result)="" buffer="*result;" buffpos="strlen(buffer);" buffmax="buffpos;" *)="" malloc(1000*sizeof(char));="" scaninbuff="1;" h="c;" start="" scanning="" while="" (*h="" &&="" (!san="" ||="" *h!="\n" ))="" h++;="" flushibp;="" h[-1]="='\n')" (san="" h--;="" mx;="" (h[-1]="='\n'" still_dd="" isalnum(*h))="" sometimes="" a="" .hp="" request="" is="" not="" followed="" by="" .br="" out_html("<dd="">");
+		curpos=0;
+		still_dd=0;
+	    }
+	    switch (*h) {
+	    case '&amp;':
+		intbuff[ibp++]='&amp;';
+		intbuff[ibp++]='a';
+		intbuff[ibp++]='m';
+		intbuff[ibp++]='p';
+		intbuff[ibp++]=';';
+		curpos++;
+		break;
+	    case '&lt;':
+		intbuff[ibp++]='&amp;';
+		intbuff[ibp++]='l';
+		intbuff[ibp++]='t';
+		intbuff[ibp++]=';';
+		curpos++;
+		break;
+	    case '&gt;':
+		intbuff[ibp++]='&amp;';
+		intbuff[ibp++]='g';
+		intbuff[ibp++]='t';
+		intbuff[ibp++]=';';
+		curpos++;
+		break;
+	    case '"':
+		intbuff[ibp++]='&amp;';
+		intbuff[ibp++]='q';
+		intbuff[ibp++]='u';
+		intbuff[ibp++]='o';
+		intbuff[ibp++]='t';
+		intbuff[ibp++]=';';
+		curpos++;
+		break;
+	    case '\n':
+		if (h[-1]=='\n' &amp;&amp; fillout) {
+		    intbuff[ibp++]='&lt;';
+		    intbuff[ibp++]='P';
+		    intbuff[ibp++]='&gt;';
+		}
+		if (contained_tab &amp;&amp; fillout) {
+		    intbuff[ibp++]='&lt;';
+		    intbuff[ibp++]='B';
+		    intbuff[ibp++]='R';
+		    intbuff[ibp++]='&gt;';
+		}
+		contained_tab=0;
+		curpos=0;
+		usenbsp=0;
+		intbuff[ibp++]='\n';
+		break;
+	    case '\t':
+		{
+		    int curtab=0;
+		    contained_tab=1;
+		    FLUSHIBP;
+		    /* like a typewriter, not like TeX */
+		    tabstops[19]=curpos+1;
+		    while (curtab<maxtstop &&="" tabstops[curtab]<="curpos)" +="" curtab++;="" if="" (curtab<maxtstop)="" {="" (!fillout)="" while="" (curpos<tabstops[curtab])="" intbuff[ibp++]=" " ;="" (ibp="">480) { FLUSHIBP; }
+				curpos++;
+			    }
+			} else {
+			    out_html("<tt>");
+			    while (curpos<tabstops[curtab]) {="" +="" out_html("&nbsp;");="" curpos++;="" }="" out_html("<="" tt="">");
+			}
+		    }
+		}
+		break;
+	    default:
+		if (*h==' ' &amp;&amp; (h[-1]=='\n' || usenbsp)) {
+		    FLUSHIBP;
+		    if (!usenbsp &amp;&amp; fillout) {
+			out_html("<br>");
+			curpos=0;
+		    }
+		    usenbsp=fillout;
+		    if (usenbsp) out_html("&nbsp;"); else intbuff[ibp++]=' ';
+		} else if (*h&gt;31 &amp;&amp; *h&lt;127) intbuff[ibp++]=*h;
+		else if (((unsigned char)(*h))&gt;127) {
+		    intbuff[ibp++]='&amp;';
+		    intbuff[ibp++]='#';
+		    intbuff[ibp++]='0'+((unsigned char)(*h))/100;
+		    intbuff[ibp++]='0'+(((unsigned char)(*h))%100)/10;
+		    intbuff[ibp++]='0'+((unsigned char)(*h))%10;
+		    intbuff[ibp++]=';';
+		}
+		curpos++;
+		break;
+	    }
+	    if (ibp&gt;480) FLUSHIBP;
+	    h++;
+	}
+    }
+    FLUSHIBP;
+    if (buffer) buffer[buffpos]='\0';
+    if (san &amp;&amp; *h) h++;
+    newline_for_fun=exnewline_for_fun;
+    if (result) {
+	*result = buffer;
+	buffer=exbuffer;
+	buffpos=exbuffpos;
+	buffmax=exbuffmax;
+	scaninbuff=exscaninbuff;
+    }
+    return h;
+}
+
+char *sectionname=NULL;
+STRDEF *foundpages=NULL;
+
+int search_manpath_all(char *name)
+{
+    char smfbuf[1000];
+    char cmpbuf[100];
+    int i,j,n,l,nr=0;
+    DIR *dr;
+    struct dirent *de;
+    STRDEF *h=NULL;
+
+    strcpy(cmpbuf,name);
+    n=strlen(name);
+    cmpbuf[n++]='.';
+    cmpbuf[n+1]='\0';
+    for (i=0; manpath[i]; i++) {
+	strcpy(smfbuf, manpath[i]);
+	l=strlen(smfbuf);
+	strcpy(smfbuf+l, "man");
+	l+=3;
+	smfbuf[l+1]='\0';
+	for (j=0; sections[j]; j++) {
+	    smfbuf[l]=sections[j];
+	    cmpbuf[n]=sections[j];
+	    if ((dr=opendir(smfbuf))) {
+		while ((de=readdir(dr))) {
+		    if (!strncmp(de-&gt;d_name, cmpbuf, n+1)) {
+			int stlen;
+			if (h) {
+			    h-&gt;next=(STRDEF*) malloc(sizeof(STRDEF));
+			    h=h-&gt;next;
+			} else
+			    h=foundpages=(STRDEF*) malloc(sizeof(STRDEF));
+			h-&gt;nr=i*256+j;
+			stlen=strlen(de-&gt;d_name)+1;
+			h-&gt;st=(char*) malloc(stlen*sizeof(char));
+			nr++;
+			strcpy(h-&gt;st, de-&gt;d_name);
+			h-&gt;next=NULL;
+		    }
+		}
+		closedir(dr);
+	    }
+	}
+    }
+    return nr;
+}
+
+int search_manpath_section(char *name, char* section)
+{
+    char smfbuf[1000];
+    char cmpbuf[100];
+    int i,j,n,l,nr=0;
+    DIR *dr;
+    struct dirent *de;
+    STRDEF *h=NULL;
+
+    if (!section) return search_manpath_all(name);
+    j=0;
+    while (sections[j] &amp;&amp; sections[j]!=section[0]) j++;
+    if (!sections[j]) return search_manpath_all(name);
+    strcpy(cmpbuf,name);
+    n=strlen(name);
+    cmpbuf[n++]='.';
+    cmpbuf[n++]=section[0];
+    cmpbuf[n]='\0';
+    for (i=0; manpath[i]; i++) {
+	strcpy(smfbuf, manpath[i]);
+	l=strlen(smfbuf);
+	strcpy(smfbuf+l, "man");
+	l+=3;
+	smfbuf[l]=section[0];
+	smfbuf[l+1]='\0';
+	if ((dr=opendir(smfbuf))) {
+	    while ((de=readdir(dr))) {
+		if (!strncmp(de-&gt;d_name, cmpbuf, n)) {
+		    int stlen;
+		    if (h) {
+			h-&gt;next=(STRDEF*) malloc(sizeof(STRDEF));
+			h=h-&gt;next;
+		    } else
+			h=foundpages=(STRDEF*) malloc(sizeof(STRDEF));
+		    h-&gt;nr=i*256+j;
+		    stlen=strlen(de-&gt;d_name)+1;
+		    h-&gt;st=(char*) malloc(stlen*sizeof(char));
+		    nr++;
+		    strcpy(h-&gt;st, de-&gt;d_name);
+		    h-&gt;next=NULL;
+		}
+	    }
+	    closedir(dr);
+	}
+    }
+    return nr;
+}
+
+static char smfbuf[1000];
+
+char *search_manpath(char *name)
+{
+    int i,j,n,l,nr=0;
+    struct stat stbuf;
+
+    for (i=0; manpath[i]; i++) {
+	strcpy(smfbuf, manpath[i]);
+	strcat(smfbuf, name);
+	if (stat(smfbuf, &amp;stbuf) !=-1) return smfbuf;
+    }
+    return NULL;
+}
+
+int main(int argc, char **argv)
+{
+    FILE *f;
+    struct stat stbuf;
+    char *t=NULL;
+    int l,i;char *buf;
+    int mopt=0;
+    int notinsection=0;
+    char *h, *fullname;
+    STRDEF *stdf;
+
+    t = getenv("PATH_INFO");
+    if (!t || !*t) /* not :  cgi/man2html/mani/name.i */ {
+	i=1;
+	while (i<argc) {="" +="" switch="" (argv[i][0])="" case="" '-':="" if="" (argv[i][1]="='M')" mopt="1;" (i+1<argc)="" char="" *s1,="" *s2;="" i++;="" l="strlen(argv[i]);" manpath[0]="(char*)" malloc(l+2);="" s1="manpath[0];" s2="argv[i];" while="" ((*s1="*s2))" (*s2="='%')" s2++;="" *s1="0;" (isdigit(*s2))="" else="" s2++;*s1="(*s1)*16;" }="" s1++;="" (s1[-1]!="/" )="" *s1++="/" ;*s1="\0" ;="" break;="" '1':="" '2':="" '3':="" '4':="" '5':="" '6':="" '7':="" '8':="" '9':="" 'n':="" 'l':="" (!argv[i][1])="" sectionname="argv[i];" (!argv[i][2]="" &&="" isalpha(argv[i][1])="" !isalpha(argv[i][0])="" islower(argv[i][1]))="" default:="" t="argv[i];" (t)="" malloc(l);="" (!t="" ||="" !*t)="" usage();="" i="0;" h="t;" (*h)="" =="/" );="" (i="=0)" (sectionname)="" fname[1000];="" sprintf(fname,="" "man%c="" %s.%s",="" sectionname[0],t,sectionname);="" (h)="" printf("location:="" "="" cgibase="" "%s\n\n",="" h);="" exit(0);="" (sectionname[1])="" fname[strlen(fname)-1]="\0" notinsection="(i">0);
+	    }
+	}
+	if (!i) i=search_manpath_all(t);
+	if (i==1 || (i&gt;1 &amp;&amp; mopt)) {
+	    printf("Location: " CGIBASE "%sman%c/%s\n\n",
+		   manpath[foundpages-&gt;nr/256],
+		   sections[foundpages-&gt;nr%256],
+		   foundpages-&gt;st);
+	    exit(0);
+	}
+	printf("Content-type: text/html\n\n"
+	       "\n<title>Index to %s manpages.</title>\n"
+	       "\n<h1>Index to %s manpages%s%c</h1>\n", t, t,
+	       (notinsection?" for section ":""),
+	       (notinsection?sectionname[0]:' '));
+	if (!i)
+	    printf("Sorry, no manpages available for %s.\n", t);
+	else {
+	    STRDEF *strd;
+	    printf("<ul>\n");
+	    strd=foundpages;
+	    while (strd) {
+		printf("<li><a href="\&quot;&quot;" cgibase="" "%sman%c="" %s\"="">"
+		       "%s</a> (%s)\n", manpath[strd-&gt;nr/256],
+		       sections[strd-&gt;nr%256], strd-&gt;st, strd-&gt;st,
+		       manpath[strd-&gt;nr/256]);
+		strd=strd-&gt;next;
+	    }
+	    printf("</li></ul>\n");
+	}
+	printf("\n");
+	exit(0);
+    }
+    printf("Content-type: text/html\n\n");
+    h=strstr(t, "man");
+    if (!h) {
+	printf("<title>Manpage: Error</title>\n"
+	       "\n<h1>Only manpages are allowed</h1>\n"
+	       "You specified a file which did not contain the keyword\n"
+	       "<b>man</b>. To view the file you wanted, use this\n"
+	       "<a href="\&quot;file:%s\&quot;">link</a> instead\n"
+	       "\n", t);
+	exit(0);
+    }
+    h=strstr(t,"/../");
+    if (h) {
+	printf("<title>Manpage: Error</title>\n"
+	       "\n<h1>Warning.</h1>\n"
+	       "You still try to get files which are manpages. Using the\n"
+	       "<b>..</b> construction to get to a different directory will\n"
+	       "<b>not</b> work either. If you try this very often, you\n"
+	       "will end up in a black list.\n"
+	       "\n");
+	exit(0);
+    }
+    h=search_manpath(t);
+    if (!h &amp;&amp; i&gt;2) {
+	char *g;
+	g=strrchr(t,'/');
+	*g='.';
+	h=strrchr(t,'/');
+	*g='/';
+	h=search_manpath(h);
+    }
+    if (!h) {
+	h=strrchr(t,'.');
+	if (h) {
+	    *h='\0';
+	    sectionname=h+1;
+	} else sectionname=NULL;
+	h=strrchr(t,'/');
+	if (!h) h=t; else h++;
+	printf("<title>No manpage for %s.</title>\n"
+	       "\n<h1>No manpage for %s.</h1>\n"
+	       "Sorry, the manpage for %s does not exist%s%s",
+	       h,h,h, (sectionname? " in section ":""),
+	       (sectionname?sectionname:""));
+       	i=search_manpath_all(h);
+	if (!i) {
+	    if (sectionname)
+		printf(",nor in any other section.\n");
+	    else
+		printf("in any section.\n");
+	    printf("<hr>\n"
+		   "The links to other manual pages are not always correct.\n"
+		   "Normally you will get a list of possible replacements,\n"
+		   "but in this case the manual page just can't be found.\n");
+	} else {
+	    STRDEF *strd;
+	    printf(".\nMaybe you can use %s instead.\n<ul>\n",
+		   (i&gt;1?"one of the following pages":"this page"));
+	    strd=foundpages;
+	    while (strd) {
+		printf("<li><a href="\&quot;&quot;" cgibase="" "%sman%c="" %s\"="">"
+		       "%s</a> (%s)\n", manpath[strd-&gt;nr/256],
+		       sections[strd-&gt;nr%256], strd-&gt;st, strd-&gt;st,
+		       manpath[strd-&gt;nr/256]);
+		strd=strd-&gt;next;
+	    }
+	    printf("</li></ul>\n");
+	}
+	printf("\n");
+	exit(0);
+    }
+    fullname=h;
+    t=strrchr(h,'/');
+    if (t) {
+	*t='\0';
+	if (!chdir(h))
+	    h=t+1;
+	*t='/';
+    }
+    if (stat(h, &amp;stbuf)!=-1) l=stbuf.st_size;
+    buf = (char*) malloc((l+5)*sizeof(char));
+    f=fopen(h,"r");
+    if (!f || !buf || !l) {
+	t=strrchr(h,'.');
+	if (t) *t='\0';
+	t=strrchr(h,'/');
+	if (!t) t=h; else t++;
+	printf("<title>No manpage for %s.</title>\n"
+	       "\n<h1>No manpage for %s.</h1>\n"
+	       "Sorry, unable to convert the manpage for %s.\n"
+	       "\n", t,t,t);
+	exit(0);
+    }
+    i=fread(buf+1,1,l,f);
+    fclose(f);
+    fname=h;
+#ifdef MAKEINDEX
+    idxfile=fopen(INDEXFILE, "a");
+#endif
+    stdf=&amp;standardchar[0];
+    i=0;
+    while (stdf-&gt;nr) {
+	stdf-&gt;next=&amp;standardchar[i];
+	stdf=stdf-&gt;next;
+	i++;
+    }
+    chardef=&amp;standardchar[0];
+    stdf=&amp;standardstring[0];
+    i=0;
+    while (stdf-&gt;nr) {
+	stdf-&gt;next=&amp;standardstring[i];
+	stdf=stdf-&gt;next;
+	i++;
+    }
+    strdef=&amp;standardstring[0];
+    intdef=&amp;standardint[0];
+    i=0;
+    while (intdef-&gt;nr) {
+	intdef-&gt;next=&amp;standardint[i];
+	intdef=intdef-&gt;next;
+	i++;
+    }
+    intdef=&amp;standardint[0];
+    defdef=NULL;
+    buf[0]='\n';
+    buf[l]='\n';
+    buf[l+1]=buf[l+2]='\0';
+    scan_troff(buf+1,0,NULL);
+    while (itemdepth || dl_set[itemdepth]) {
+	out_html("\n");
+	if (dl_set[itemdepth]) dl_set[itemdepth]=0;
+	else itemdepth--;
+    }
+    out_html(change_to_font(0));
+    out_html(change_to_size(0));
+    if (!fillout) {
+	fillout=1;
+	out_html("");
+    }
+    out_html(NEWLINE);
+    if (output_possible) {
+	/* &nbsp; for mosaic users */
+	printf("<hr>\n<a name="\&quot;index\&quot;">&nbsp;</a><h2>Index</h2>\n<dl>\n");
+	manidx[mip]=0;
+	printf(manidx);
+	if (subs) printf("</dl>\n");
+	printf("\n");
+	print_sig();
+	printf("\n\n");
+    } else {
+	printf("<title>Invalid Manpage</title>\n"
+	       "<h1>Invalid Manpage</h1>\n"
+	       "You tried to retrieve an incorrect manpage.\n"
+	       "The page does not contain a manpage header and will\n"
+	       "not produce any output.\n"
+	       "If the page is a formatted manpage, you might want to use\n"
+	       "a different man2html (or cat2html) converter.\n"
+	       "You can also try to load the\n"
+	       "<a href="\&quot;file://localhost%s\&quot;">plain file</a>\n",
+	       fullname);
+	print_sig();
+	printf("\n\n");
+    }
+#ifdef MAKEINDEX
+    if (idxfile) fclose(idxfile);
+#endif
+    if (buf) free(buf);
+}
</argc)></tabstops[curtab])></tt></maxtstop></words;></words;></olen;></words;></ti-></h)></font></li></dd></isindex></isindex></sys></time.h></michael@actrix.gen.nz></michael@actrix.gen.nz></body></html>